diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2012-10-03 10:23:15 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2012-10-03 10:23:15 +0200 |
commit | 3d9b832439afeb1b05c60831e0865df585dc55ac (patch) | |
tree | a0796f2b6a97ceb6c257cad516b62083aacb55da | |
parent | 9e2703f7ca0b35129a94465654d0e18d14048dbc (diff) | |
download | egawk-3d9b832439afeb1b05c60831e0865df585dc55ac.tar.gz egawk-3d9b832439afeb1b05c60831e0865df585dc55ac.tar.bz2 egawk-3d9b832439afeb1b05c60831e0865df585dc55ac.zip |
More SYMTAB and FUNCTAB improvements.
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | awk.h | 1 | ||||
-rw-r--r-- | awkgram.c | 16 | ||||
-rw-r--r-- | awkgram.y | 16 | ||||
-rw-r--r-- | doc/ChangeLog | 3 | ||||
-rw-r--r-- | doc/gawk.1 | 10 | ||||
-rw-r--r-- | doc/gawk.info | 566 | ||||
-rw-r--r-- | doc/gawk.texi | 8 | ||||
-rw-r--r-- | interpret.h | 17 | ||||
-rw-r--r-- | symbol.c | 7 |
10 files changed, 357 insertions, 299 deletions
@@ -1,6 +1,16 @@ 2012-10-02 Arnold D. Robbins <arnold@skeeve.com> - * symbol.c (lookup): If do_posix, skip the global table. + * awk.h (func_table): Declare. + * awkgram.y: If do_posix or do_traditional, then check for + delete on SYMTAB. Add check for delete on FUNCTAB, also. + * interpret.h (Op_Subscript): For FUNCTAB, return the element name + as its value too. Avoids lots of weirdness and allows indirect calls + after assignment from FUNCTAB["foo"] to work. + (Op_store_sub): Disallow assignment to elements of FUNCTAB. + (Op_indirect_func_all): Turn assert into check and fatal error. + * symbol.c (func_table): No longer static. + (lookup): If do_posix or do_traditional, skip the global table. + (release_all_vars): Clear func_table too. 2012-09-25 Arnold D. Robbins <arnold@skeeve.com> @@ -1666,6 +1666,7 @@ extern int get_numbase(const char *str, bool use_locale); extern void load_symbols(); extern void init_symbol_table(); extern NODE *symbol_table; +extern NODE *func_table; extern NODE *install_symbol(char *name, NODETYPE type); extern NODE *remove_symbol(NODE *r); extern void destroy_symbol(NODE *r); @@ -2990,8 +2990,12 @@ regular_print: (yyvsp[(2) - (4)])->opcode = Op_push_array; (yyvsp[(2) - (4)])->memory = variable((yyvsp[(2) - (4)])->source_line, arr, Node_var_new); - if ((yyvsp[(2) - (4)])->memory == symbol_table) - fatal(_("`delete' is not allowed with SYMTAB")); + if (! do_posix && ! do_traditional) { + if ((yyvsp[(2) - (4)])->memory == symbol_table) + fatal(_("`delete' is not allowed with SYMTAB")); + else if ((yyvsp[(2) - (4)])->memory == func_table) + fatal(_("`delete' is not allowed with FUNCTAB")); + } if ((yyvsp[(4) - (4)]) == NULL) { /* @@ -3035,8 +3039,12 @@ regular_print: (yyvsp[(1) - (4)])->expr_count = 0; (yyval) = list_append(list_create((yyvsp[(3) - (4)])), (yyvsp[(1) - (4)])); - if ((yyvsp[(3) - (4)])->memory == symbol_table) - fatal(_("`delete' is not allowed with SYMTAB")); + if (! do_posix && ! do_traditional) { + if ((yyvsp[(3) - (4)])->memory == symbol_table) + fatal(_("`delete' is not allowed with SYMTAB")); + else if ((yyvsp[(3) - (4)])->memory == func_table) + fatal(_("`delete' is not allowed with FUNCTAB")); + } } break; @@ -973,8 +973,12 @@ regular_print: $2->opcode = Op_push_array; $2->memory = variable($2->source_line, arr, Node_var_new); - if ($2->memory == symbol_table) - fatal(_("`delete' is not allowed with SYMTAB")); + if (! do_posix && ! do_traditional) { + if ($2->memory == symbol_table) + fatal(_("`delete' is not allowed with SYMTAB")); + else if ($2->memory == func_table) + fatal(_("`delete' is not allowed with FUNCTAB")); + } if ($4 == NULL) { /* @@ -1018,8 +1022,12 @@ regular_print: $1->expr_count = 0; $$ = list_append(list_create($3), $1); - if ($3->memory == symbol_table) - fatal(_("`delete' is not allowed with SYMTAB")); + if (! do_posix && ! do_traditional) { + if ($3->memory == symbol_table) + fatal(_("`delete' is not allowed with SYMTAB")); + else if ($3->memory == func_table) + fatal(_("`delete' is not allowed with FUNCTAB")); + } } | exp { $$ = optimize_assignment($1); } diff --git a/doc/ChangeLog b/doc/ChangeLog index 0efd3f73..054238ec 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,7 +1,8 @@ 2012-10-02 Arnold D. Robbins <arnold@skeeve.com> * gawk.texi, gawk.1, awkcard.in: Document FUNCTAB, SYMTAB, and - PROCINFO["identifiers"]. + PROCINFO["identifiers"]. Including that delete does not work + on FUNCTAB and SYMTAB. 2012-09-23 Arnold D. Robbins <arnold@skeeve.com> @@ -994,6 +994,11 @@ An array whose indices are the names of all the user-defined or extension functions in the program. .BR NOTE : The array values cannot currently be used. +Also, you may not use the +.B delete +statment with the +.B FUNCTAB +array. .TP .B IGNORECASE Controls the case-sensitivity of all regular expression @@ -1289,6 +1294,11 @@ The function may be used to test if an element in .B SYMTAB is an array. +You may not use the +.B delete +statment with the +.B SYMTAB +array. .TP .B TEXTDOMAIN The text domain of the \*(AK program; used to find the localized diff --git a/doc/gawk.info b/doc/gawk.info index 67fb4a1b..44b48e56 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -9605,7 +9605,8 @@ with a pound sign (`#'). `FUNCTAB #' An array whose indices are the names of all the user-defined or extension functions in the program. *NOTE*: The array values - cannot currently be used. + cannot currently be used. Also, you may not use the `delete' + statement with the `FUNCTAB' array. `NR' The number of input records `awk' has processed since the @@ -9746,12 +9747,12 @@ with a pound sign (`#'). print foo # prints 4 The `isarray()' function (*note Type Functions::) may be used to - test if an element in `SYMTAB' is an array. + test if an element in `SYMTAB' is an array. Also, you may not use + the `delete' statement with the `SYMTAB' array. - NOTE: In order to avoid severe time-travel paradoxes (as well - as to avoid difficult implementation issues), neither - `FUNCTAB' nor `SYMTAB' are available as elements within the - `SYMTAB' array. + NOTE: In order to avoid severe time-travel paradoxes(2), + neither `FUNCTAB' nor `SYMTAB' are available as elements + within the `SYMTAB' array. Advanced Notes: Changing `NR' and `FNR' --------------------------------------- @@ -9782,6 +9783,8 @@ file by resetting `NR' to zero when `FILENAME' changed. to `"-"', even if there were data files to be processed. This behavior was incorrect and should not be relied upon in your programs. + (2) Not to mention difficult implementation issues. + File: gawk.info, Node: ARGC and ARGV, Prev: Auto-set, Up: Built-in Variables @@ -26015,7 +26018,7 @@ Index (line 67) * advanced features, data files as single record: Records. (line 180) * advanced features, fixed-width data: Constant Size. (line 9) -* advanced features, FNR/NR variables: Auto-set. (line 273) +* advanced features, FNR/NR variables: Auto-set. (line 274) * advanced features, gawk: Advanced Features. (line 6) * advanced features, gawk, network programming: TCP/IP Networking. (line 6) @@ -26520,7 +26523,7 @@ Index (line 47) * dark corner, FILENAME variable <1>: Auto-set. (line 93) * dark corner, FILENAME variable: Getline Notes. (line 19) -* dark corner, FNR/NR variables: Auto-set. (line 273) +* dark corner, FNR/NR variables: Auto-set. (line 274) * dark corner, format-control characters: Control Letters. (line 18) * dark corner, FS as null string: Single Character Fields. (line 20) @@ -26715,14 +26718,14 @@ Index (line 6) * differences in awk and gawk, print/printf statements: Format Modifiers. (line 13) -* differences in awk and gawk, PROCINFO array: Auto-set. (line 129) +* differences in awk and gawk, PROCINFO array: Auto-set. (line 130) * differences in awk and gawk, record separators: Records. (line 117) * differences in awk and gawk, regexp constants: Using Constant Regexps. (line 43) * differences in awk and gawk, regular expressions: Case-sensitivity. (line 26) * differences in awk and gawk, RS/RT variables: Records. (line 172) -* differences in awk and gawk, RT variable: Auto-set. (line 245) +* differences in awk and gawk, RT variable: Auto-set. (line 246) * differences in awk and gawk, single-character fields: Single Character Fields. (line 6) * differences in awk and gawk, split() function: String Functions. @@ -26731,7 +26734,7 @@ Index * differences in awk and gawk, strings, storing: Records. (line 192) * differences in awk and gawk, strtonum() function (gawk): String Functions. (line 404) -* differences in awk and gawk, SYMTAB variable: Auto-set. (line 253) +* differences in awk and gawk, SYMTAB variable: Auto-set. (line 254) * differences in awk and gawk, TEXTDOMAIN variable: User-modified. (line 162) * differences in awk and gawk, trunc-mod operation: Arithmetic Ops. @@ -27002,7 +27005,7 @@ Index * floating-point, numbers: General Arithmetic. (line 6) * FNR variable <1>: Auto-set. (line 103) * FNR variable: Records. (line 6) -* FNR variable, changing: Auto-set. (line 273) +* FNR variable, changing: Auto-set. (line 274) * for statement: For Statement. (line 6) * for statement, in arrays: Scanning an Array. (line 20) * format specifiers, mixing regular with positional specifiers: Printf Ordering. @@ -27165,7 +27168,7 @@ Index * gawk, OS/2 version of: PC Using. (line 11) * gawk, PROCINFO array in <1>: Two-way I/O. (line 116) * gawk, PROCINFO array in <2>: Time Functions. (line 46) -* gawk, PROCINFO array in: Auto-set. (line 129) +* gawk, PROCINFO array in: Auto-set. (line 130) * gawk, regexp constants and: Using Constant Regexps. (line 28) * gawk, regular expressions, case sensitivity: Case-sensitivity. @@ -27173,7 +27176,7 @@ Index * gawk, regular expressions, operators: GNU Regexp Operators. (line 6) * gawk, regular expressions, precedence: Regexp Operators. (line 161) -* gawk, RT variable in <1>: Auto-set. (line 245) +* gawk, RT variable in <1>: Auto-set. (line 246) * gawk, RT variable in <2>: Getline/Variable/File. (line 10) * gawk, RT variable in <3>: Multiple Line. (line 129) @@ -27182,7 +27185,7 @@ Index * gawk, source code, obtaining: Getting. (line 6) * gawk, splitting fields and: Constant Size. (line 87) * gawk, string-translation functions: I18N Functions. (line 6) -* gawk, SYMTAB array in: Auto-set. (line 253) +* gawk, SYMTAB array in: Auto-set. (line 254) * gawk, TEXTDOMAIN variable in: User-modified. (line 162) * gawk, timestamps: Time Functions. (line 6) * gawk, uses for: Preface. (line 36) @@ -27585,9 +27588,9 @@ Index (line 49) * noassign.awk program: Ignoring Assigns. (line 15) * not Boolean-logic operator: Boolean Ops. (line 6) -* NR variable <1>: Auto-set. (line 124) +* NR variable <1>: Auto-set. (line 125) * NR variable: Records. (line 6) -* NR variable, changing: Auto-set. (line 273) +* NR variable, changing: Auto-set. (line 274) * null strings <1>: Basic Data Typing. (line 26) * null strings <2>: Truth Values. (line 6) * null strings <3>: Regexp Field Splitting. @@ -27870,7 +27873,7 @@ Index * PROCINFO array <3>: Passwd Functions. (line 6) * PROCINFO array <4>: Two-way I/O. (line 116) * PROCINFO array <5>: Time Functions. (line 46) -* PROCINFO array <6>: Auto-set. (line 129) +* PROCINFO array <6>: Auto-set. (line 130) * PROCINFO array: Obsolete. (line 11) * profiling awk programs: Profiling. (line 6) * profiling awk programs, dynamically: Profiling. (line 171) @@ -28012,7 +28015,7 @@ Index * right angle bracket (>), >> operator (I/O): Redirection. (line 50) * right shift, bitwise: Bitwise Functions. (line 32) * Ritchie, Dennis: Basic Data Typing. (line 55) -* RLENGTH variable: Auto-set. (line 232) +* RLENGTH variable: Auto-set. (line 233) * RLENGTH variable, match() function and: String Functions. (line 223) * Robbins, Arnold <1>: Future Extensions. (line 6) * Robbins, Arnold <2>: Bugs. (line 32) @@ -28039,9 +28042,9 @@ Index * RS variable: Records. (line 20) * RS variable, multiline records and: Multiple Line. (line 17) * rshift() function (gawk): Bitwise Functions. (line 52) -* RSTART variable: Auto-set. (line 238) +* RSTART variable: Auto-set. (line 239) * RSTART variable, match() function and: String Functions. (line 223) -* RT variable <1>: Auto-set. (line 245) +* RT variable <1>: Auto-set. (line 246) * RT variable <2>: Getline/Variable/File. (line 10) * RT variable <3>: Multiple Line. (line 129) @@ -28233,7 +28236,7 @@ Index * substr() function: String Functions. (line 481) * Sumner, Andrew: Other Versions. (line 55) * switch statement: Switch Statement. (line 6) -* SYMTAB array: Auto-set. (line 253) +* SYMTAB array: Auto-set. (line 254) * syntactic ambiguity: /= operator vs. /=.../ regexp constant: Assignment Ops. (line 148) * system() function: I/O Functions. (line 63) @@ -28667,264 +28670,265 @@ Node: Built-in Variables393879 Node: User-modified394974 Ref: User-modified-Footnote-1403329 Node: Auto-set403391 -Ref: Auto-set-Footnote-1414993 -Node: ARGC and ARGV415198 -Node: Arrays419049 -Node: Array Basics420554 -Node: Array Intro421380 -Node: Reference to Elements425698 -Node: Assigning Elements427968 -Node: Array Example428459 -Node: Scanning an Array430191 -Node: Controlling Scanning432505 -Ref: Controlling Scanning-Footnote-1437438 -Node: Delete437754 -Ref: Delete-Footnote-1440519 -Node: Numeric Array Subscripts440576 -Node: Uninitialized Subscripts442759 -Node: Multi-dimensional444387 -Node: Multi-scanning447481 -Node: Arrays of Arrays449072 -Node: Functions453717 -Node: Built-in454539 -Node: Calling Built-in455617 -Node: Numeric Functions457605 -Ref: Numeric Functions-Footnote-1461437 -Ref: Numeric Functions-Footnote-2461794 -Ref: Numeric Functions-Footnote-3461842 -Node: String Functions462111 -Ref: String Functions-Footnote-1485608 -Ref: String Functions-Footnote-2485737 -Ref: String Functions-Footnote-3485985 -Node: Gory Details486072 -Ref: table-sub-escapes487751 -Ref: table-sub-posix-92489105 -Ref: table-sub-proposed490448 -Ref: table-posix-sub491798 -Ref: table-gensub-escapes493344 -Ref: Gory Details-Footnote-1494551 -Ref: Gory Details-Footnote-2494602 -Node: I/O Functions494753 -Ref: I/O Functions-Footnote-1501408 -Node: Time Functions501555 -Ref: Time Functions-Footnote-1512447 -Ref: Time Functions-Footnote-2512515 -Ref: Time Functions-Footnote-3512673 -Ref: Time Functions-Footnote-4512784 -Ref: Time Functions-Footnote-5512896 -Ref: Time Functions-Footnote-6513123 -Node: Bitwise Functions513389 -Ref: table-bitwise-ops513947 -Ref: Bitwise Functions-Footnote-1518168 -Node: Type Functions518352 -Node: I18N Functions518822 -Node: User-defined520449 -Node: Definition Syntax521253 -Ref: Definition Syntax-Footnote-1526163 -Node: Function Example526232 -Node: Function Caveats528826 -Node: Calling A Function529247 -Node: Variable Scope530362 -Node: Pass By Value/Reference532337 -Node: Return Statement535777 -Node: Dynamic Typing538758 -Node: Indirect Calls539493 -Node: Internationalization549178 -Node: I18N and L10N550604 -Node: Explaining gettext551290 -Ref: Explaining gettext-Footnote-1556356 -Ref: Explaining gettext-Footnote-2556540 -Node: Programmer i18n556705 -Node: Translator i18n560905 -Node: String Extraction561698 -Ref: String Extraction-Footnote-1562659 -Node: Printf Ordering562745 -Ref: Printf Ordering-Footnote-1565529 -Node: I18N Portability565593 -Ref: I18N Portability-Footnote-1568042 -Node: I18N Example568105 -Ref: I18N Example-Footnote-1570740 -Node: Gawk I18N570812 -Node: Advanced Features571429 -Node: Nondecimal Data572942 -Node: Array Sorting574525 -Node: Controlling Array Traversal575222 -Node: Array Sorting Functions583460 -Ref: Array Sorting Functions-Footnote-1587134 -Ref: Array Sorting Functions-Footnote-2587227 -Node: Two-way I/O587421 -Ref: Two-way I/O-Footnote-1592853 -Node: TCP/IP Networking592923 -Node: Profiling595767 -Node: Library Functions603221 -Ref: Library Functions-Footnote-1606228 -Node: Library Names606399 -Ref: Library Names-Footnote-1609870 -Ref: Library Names-Footnote-2610090 -Node: General Functions610176 -Node: Strtonum Function611129 -Node: Assert Function614059 -Node: Round Function617385 -Node: Cliff Random Function618928 -Node: Ordinal Functions619944 -Ref: Ordinal Functions-Footnote-1623014 -Ref: Ordinal Functions-Footnote-2623266 -Node: Join Function623475 -Ref: Join Function-Footnote-1625246 -Node: Getlocaltime Function625446 -Node: Data File Management629161 -Node: Filetrans Function629793 -Node: Rewind Function633932 -Node: File Checking635319 -Node: Empty Files636413 -Node: Ignoring Assigns638643 -Node: Getopt Function640196 -Ref: Getopt Function-Footnote-1651500 -Node: Passwd Functions651703 -Ref: Passwd Functions-Footnote-1660678 -Node: Group Functions660766 -Node: Walking Arrays668850 -Node: Sample Programs670419 -Node: Running Examples671084 -Node: Clones671812 -Node: Cut Program673036 -Node: Egrep Program682881 -Ref: Egrep Program-Footnote-1690654 -Node: Id Program690764 -Node: Split Program694380 -Ref: Split Program-Footnote-1697899 -Node: Tee Program698027 -Node: Uniq Program700830 -Node: Wc Program708259 -Ref: Wc Program-Footnote-1712525 -Ref: Wc Program-Footnote-2712725 -Node: Miscellaneous Programs712817 -Node: Dupword Program714005 -Node: Alarm Program716036 -Node: Translate Program720785 -Ref: Translate Program-Footnote-1725172 -Ref: Translate Program-Footnote-2725400 -Node: Labels Program725534 -Ref: Labels Program-Footnote-1728905 -Node: Word Sorting728989 -Node: History Sorting732873 -Node: Extract Program734712 -Ref: Extract Program-Footnote-1742195 -Node: Simple Sed742323 -Node: Igawk Program745385 -Ref: Igawk Program-Footnote-1760542 -Ref: Igawk Program-Footnote-2760743 -Node: Anagram Program760881 -Node: Signature Program763949 -Node: Debugger765049 -Node: Debugging766015 -Node: Debugging Concepts766448 -Node: Debugging Terms768304 -Node: Awk Debugging770901 -Node: Sample Debugging Session771793 -Node: Debugger Invocation772313 -Node: Finding The Bug773642 -Node: List of Debugger Commands780130 -Node: Breakpoint Control781464 -Node: Debugger Execution Control785128 -Node: Viewing And Changing Data788488 -Node: Execution Stack791844 -Node: Debugger Info793311 -Node: Miscellaneous Debugger Commands797292 -Node: Readline Support802737 -Node: Limitations803568 -Node: Arbitrary Precision Arithmetic805820 -Ref: Arbitrary Precision Arithmetic-Footnote-1807462 -Node: General Arithmetic807610 -Node: Floating Point Issues809330 -Node: String Conversion Precision810211 -Ref: String Conversion Precision-Footnote-1811917 -Node: Unexpected Results812026 -Node: POSIX Floating Point Problems814179 -Ref: POSIX Floating Point Problems-Footnote-1818004 -Node: Integer Programming818042 -Node: Floating-point Programming819795 -Ref: Floating-point Programming-Footnote-1826104 -Node: Floating-point Representation826368 -Node: Floating-point Context827533 -Ref: table-ieee-formats828375 -Node: Rounding Mode829759 -Ref: table-rounding-modes830238 -Ref: Rounding Mode-Footnote-1833242 -Node: Gawk and MPFR833423 -Node: Arbitrary Precision Floats834665 -Ref: Arbitrary Precision Floats-Footnote-1837094 -Node: Setting Precision837405 -Node: Setting Rounding Mode840138 -Ref: table-gawk-rounding-modes840542 -Node: Floating-point Constants841722 -Node: Changing Precision843146 -Ref: Changing Precision-Footnote-1844546 -Node: Exact Arithmetic844720 -Node: Arbitrary Precision Integers847828 -Ref: Arbitrary Precision Integers-Footnote-1850828 -Node: Dynamic Extensions850975 -Node: Plugin License851893 -Node: Sample Library852507 -Node: Internal File Description853191 -Node: Internal File Ops856904 -Ref: Internal File Ops-Footnote-1861467 -Node: Using Internal File Ops861607 -Node: Language History863983 -Node: V7/SVR3.1865505 -Node: SVR4867826 -Node: POSIX869268 -Node: BTL870276 -Node: POSIX/GNU871010 -Node: Common Extensions876545 -Node: Ranges and Locales877652 -Ref: Ranges and Locales-Footnote-1882270 -Ref: Ranges and Locales-Footnote-2882297 -Ref: Ranges and Locales-Footnote-3882557 -Node: Contributors882778 -Node: Installation887074 -Node: Gawk Distribution887968 -Node: Getting888452 -Node: Extracting889278 -Node: Distribution contents890970 -Node: Unix Installation896192 -Node: Quick Installation896809 -Node: Additional Configuration Options898771 -Node: Configuration Philosophy900248 -Node: Non-Unix Installation902590 -Node: PC Installation903048 -Node: PC Binary Installation904347 -Node: PC Compiling906195 -Node: PC Testing909139 -Node: PC Using910315 -Node: Cygwin914500 -Node: MSYS915500 -Node: VMS Installation916014 -Node: VMS Compilation916617 -Ref: VMS Compilation-Footnote-1917624 -Node: VMS Installation Details917682 -Node: VMS Running919317 -Node: VMS Old Gawk920924 -Node: Bugs921398 -Node: Other Versions925250 -Node: Notes930565 -Node: Compatibility Mode931152 -Node: Additions931935 -Node: Accessing The Source932862 -Node: Adding Code934288 -Node: New Ports940330 -Node: Derived Files944465 -Ref: Derived Files-Footnote-1949770 -Ref: Derived Files-Footnote-2949804 -Ref: Derived Files-Footnote-3950404 -Node: Future Extensions950502 -Node: Basic Concepts951989 -Node: Basic High Level952670 -Ref: Basic High Level-Footnote-1956705 -Node: Basic Data Typing956890 -Node: Glossary960245 -Node: Copying985221 -Node: GNU Free Documentation License1022778 -Node: Index1047915 +Ref: Auto-set-Footnote-1415085 +Ref: Auto-set-Footnote-2415290 +Node: ARGC and ARGV415346 +Node: Arrays419197 +Node: Array Basics420702 +Node: Array Intro421528 +Node: Reference to Elements425846 +Node: Assigning Elements428116 +Node: Array Example428607 +Node: Scanning an Array430339 +Node: Controlling Scanning432653 +Ref: Controlling Scanning-Footnote-1437586 +Node: Delete437902 +Ref: Delete-Footnote-1440667 +Node: Numeric Array Subscripts440724 +Node: Uninitialized Subscripts442907 +Node: Multi-dimensional444535 +Node: Multi-scanning447629 +Node: Arrays of Arrays449220 +Node: Functions453865 +Node: Built-in454687 +Node: Calling Built-in455765 +Node: Numeric Functions457753 +Ref: Numeric Functions-Footnote-1461585 +Ref: Numeric Functions-Footnote-2461942 +Ref: Numeric Functions-Footnote-3461990 +Node: String Functions462259 +Ref: String Functions-Footnote-1485756 +Ref: String Functions-Footnote-2485885 +Ref: String Functions-Footnote-3486133 +Node: Gory Details486220 +Ref: table-sub-escapes487899 +Ref: table-sub-posix-92489253 +Ref: table-sub-proposed490596 +Ref: table-posix-sub491946 +Ref: table-gensub-escapes493492 +Ref: Gory Details-Footnote-1494699 +Ref: Gory Details-Footnote-2494750 +Node: I/O Functions494901 +Ref: I/O Functions-Footnote-1501556 +Node: Time Functions501703 +Ref: Time Functions-Footnote-1512595 +Ref: Time Functions-Footnote-2512663 +Ref: Time Functions-Footnote-3512821 +Ref: Time Functions-Footnote-4512932 +Ref: Time Functions-Footnote-5513044 +Ref: Time Functions-Footnote-6513271 +Node: Bitwise Functions513537 +Ref: table-bitwise-ops514095 +Ref: Bitwise Functions-Footnote-1518316 +Node: Type Functions518500 +Node: I18N Functions518970 +Node: User-defined520597 +Node: Definition Syntax521401 +Ref: Definition Syntax-Footnote-1526311 +Node: Function Example526380 +Node: Function Caveats528974 +Node: Calling A Function529395 +Node: Variable Scope530510 +Node: Pass By Value/Reference532485 +Node: Return Statement535925 +Node: Dynamic Typing538906 +Node: Indirect Calls539641 +Node: Internationalization549326 +Node: I18N and L10N550752 +Node: Explaining gettext551438 +Ref: Explaining gettext-Footnote-1556504 +Ref: Explaining gettext-Footnote-2556688 +Node: Programmer i18n556853 +Node: Translator i18n561053 +Node: String Extraction561846 +Ref: String Extraction-Footnote-1562807 +Node: Printf Ordering562893 +Ref: Printf Ordering-Footnote-1565677 +Node: I18N Portability565741 +Ref: I18N Portability-Footnote-1568190 +Node: I18N Example568253 +Ref: I18N Example-Footnote-1570888 +Node: Gawk I18N570960 +Node: Advanced Features571577 +Node: Nondecimal Data573090 +Node: Array Sorting574673 +Node: Controlling Array Traversal575370 +Node: Array Sorting Functions583608 +Ref: Array Sorting Functions-Footnote-1587282 +Ref: Array Sorting Functions-Footnote-2587375 +Node: Two-way I/O587569 +Ref: Two-way I/O-Footnote-1593001 +Node: TCP/IP Networking593071 +Node: Profiling595915 +Node: Library Functions603369 +Ref: Library Functions-Footnote-1606376 +Node: Library Names606547 +Ref: Library Names-Footnote-1610018 +Ref: Library Names-Footnote-2610238 +Node: General Functions610324 +Node: Strtonum Function611277 +Node: Assert Function614207 +Node: Round Function617533 +Node: Cliff Random Function619076 +Node: Ordinal Functions620092 +Ref: Ordinal Functions-Footnote-1623162 +Ref: Ordinal Functions-Footnote-2623414 +Node: Join Function623623 +Ref: Join Function-Footnote-1625394 +Node: Getlocaltime Function625594 +Node: Data File Management629309 +Node: Filetrans Function629941 +Node: Rewind Function634080 +Node: File Checking635467 +Node: Empty Files636561 +Node: Ignoring Assigns638791 +Node: Getopt Function640344 +Ref: Getopt Function-Footnote-1651648 +Node: Passwd Functions651851 +Ref: Passwd Functions-Footnote-1660826 +Node: Group Functions660914 +Node: Walking Arrays668998 +Node: Sample Programs670567 +Node: Running Examples671232 +Node: Clones671960 +Node: Cut Program673184 +Node: Egrep Program683029 +Ref: Egrep Program-Footnote-1690802 +Node: Id Program690912 +Node: Split Program694528 +Ref: Split Program-Footnote-1698047 +Node: Tee Program698175 +Node: Uniq Program700978 +Node: Wc Program708407 +Ref: Wc Program-Footnote-1712673 +Ref: Wc Program-Footnote-2712873 +Node: Miscellaneous Programs712965 +Node: Dupword Program714153 +Node: Alarm Program716184 +Node: Translate Program720933 +Ref: Translate Program-Footnote-1725320 +Ref: Translate Program-Footnote-2725548 +Node: Labels Program725682 +Ref: Labels Program-Footnote-1729053 +Node: Word Sorting729137 +Node: History Sorting733021 +Node: Extract Program734860 +Ref: Extract Program-Footnote-1742343 +Node: Simple Sed742471 +Node: Igawk Program745533 +Ref: Igawk Program-Footnote-1760690 +Ref: Igawk Program-Footnote-2760891 +Node: Anagram Program761029 +Node: Signature Program764097 +Node: Debugger765197 +Node: Debugging766163 +Node: Debugging Concepts766596 +Node: Debugging Terms768452 +Node: Awk Debugging771049 +Node: Sample Debugging Session771941 +Node: Debugger Invocation772461 +Node: Finding The Bug773790 +Node: List of Debugger Commands780278 +Node: Breakpoint Control781612 +Node: Debugger Execution Control785276 +Node: Viewing And Changing Data788636 +Node: Execution Stack791992 +Node: Debugger Info793459 +Node: Miscellaneous Debugger Commands797440 +Node: Readline Support802885 +Node: Limitations803716 +Node: Arbitrary Precision Arithmetic805968 +Ref: Arbitrary Precision Arithmetic-Footnote-1807610 +Node: General Arithmetic807758 +Node: Floating Point Issues809478 +Node: String Conversion Precision810359 +Ref: String Conversion Precision-Footnote-1812065 +Node: Unexpected Results812174 +Node: POSIX Floating Point Problems814327 +Ref: POSIX Floating Point Problems-Footnote-1818152 +Node: Integer Programming818190 +Node: Floating-point Programming819943 +Ref: Floating-point Programming-Footnote-1826252 +Node: Floating-point Representation826516 +Node: Floating-point Context827681 +Ref: table-ieee-formats828523 +Node: Rounding Mode829907 +Ref: table-rounding-modes830386 +Ref: Rounding Mode-Footnote-1833390 +Node: Gawk and MPFR833571 +Node: Arbitrary Precision Floats834813 +Ref: Arbitrary Precision Floats-Footnote-1837242 +Node: Setting Precision837553 +Node: Setting Rounding Mode840286 +Ref: table-gawk-rounding-modes840690 +Node: Floating-point Constants841870 +Node: Changing Precision843294 +Ref: Changing Precision-Footnote-1844694 +Node: Exact Arithmetic844868 +Node: Arbitrary Precision Integers847976 +Ref: Arbitrary Precision Integers-Footnote-1850976 +Node: Dynamic Extensions851123 +Node: Plugin License852041 +Node: Sample Library852655 +Node: Internal File Description853339 +Node: Internal File Ops857052 +Ref: Internal File Ops-Footnote-1861615 +Node: Using Internal File Ops861755 +Node: Language History864131 +Node: V7/SVR3.1865653 +Node: SVR4867974 +Node: POSIX869416 +Node: BTL870424 +Node: POSIX/GNU871158 +Node: Common Extensions876693 +Node: Ranges and Locales877800 +Ref: Ranges and Locales-Footnote-1882418 +Ref: Ranges and Locales-Footnote-2882445 +Ref: Ranges and Locales-Footnote-3882705 +Node: Contributors882926 +Node: Installation887222 +Node: Gawk Distribution888116 +Node: Getting888600 +Node: Extracting889426 +Node: Distribution contents891118 +Node: Unix Installation896340 +Node: Quick Installation896957 +Node: Additional Configuration Options898919 +Node: Configuration Philosophy900396 +Node: Non-Unix Installation902738 +Node: PC Installation903196 +Node: PC Binary Installation904495 +Node: PC Compiling906343 +Node: PC Testing909287 +Node: PC Using910463 +Node: Cygwin914648 +Node: MSYS915648 +Node: VMS Installation916162 +Node: VMS Compilation916765 +Ref: VMS Compilation-Footnote-1917772 +Node: VMS Installation Details917830 +Node: VMS Running919465 +Node: VMS Old Gawk921072 +Node: Bugs921546 +Node: Other Versions925398 +Node: Notes930713 +Node: Compatibility Mode931300 +Node: Additions932083 +Node: Accessing The Source933010 +Node: Adding Code934436 +Node: New Ports940478 +Node: Derived Files944613 +Ref: Derived Files-Footnote-1949918 +Ref: Derived Files-Footnote-2949952 +Ref: Derived Files-Footnote-3950552 +Node: Future Extensions950650 +Node: Basic Concepts952137 +Node: Basic High Level952818 +Ref: Basic High Level-Footnote-1956853 +Node: Basic Data Typing957038 +Node: Glossary960393 +Node: Copying985369 +Node: GNU Free Documentation License1022926 +Node: Index1048063 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index eb840fff..15e5b4ce 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -13022,6 +13022,8 @@ current record. @xref{Changing Fields}. An array whose indices are the names of all the user-defined or extension functions in the program. @strong{NOTE}: The array values cannot currently be used. +Also, you may not use the @code{delete} statement with the +@code{FUNCTAB} array. @cindex @code{NR} variable @item NR @@ -13196,10 +13198,12 @@ print foo # prints 4 @noindent The @code{isarray()} function (@pxref{Type Functions}) may be used to test if an element in @code{SYMTAB} is an array. +Also, you may not use the @code{delete} statement with the +@code{SYMTAB} array. @quotation NOTE -In order to avoid severe time-travel paradoxes (as well as to avoid -difficult implementation issues), neither @code{FUNCTAB} nor @code{SYMTAB} +In order to avoid severe time-travel paradoxes@footnote{Not to mention difficult +implementation issues.}, neither @code{FUNCTAB} nor @code{SYMTAB} are available as elements within the @code{SYMTAB} array. @end quotation @end table diff --git a/interpret.h b/interpret.h index 208155a7..5bd3e3a6 100644 --- a/interpret.h +++ b/interpret.h @@ -210,9 +210,15 @@ top: lintwarn(_("subscript of array `%s' is null string"), array_vname(t1)); } - r = *assoc_lookup(t1, t2); + /* for FUNCTAB, get the name as the element value */ + if (t1 == func_table) { + r = t2; + } else { + r = *assoc_lookup(t1, t2); + } DEREF(t2); + /* for SYMTAB, step through to the actual variable */ if (t1 == symbol_table && r->type == Node_var) r = r->var_value; @@ -536,7 +542,9 @@ mod: } DEREF(t2); - if (t1 == symbol_table && (*lhs)->type == Node_var) + if (t1 == func_table) + fatal(_("cannot assign to elements of FUNCTAB")); + else if (t1 == symbol_table && (*lhs)->type == Node_var) lhs = & ((*lhs)->var_value); unref(*lhs); @@ -884,7 +892,10 @@ match_re: arg_count = (pc + 1)->expr_count; t1 = PEEK(arg_count); /* indirect var */ - assert(t1->type == Node_val); /* @a[1](p) not allowed in grammar */ + + if (t1->type != Node_val) /* @a[1](p) not allowed in grammar */ + fatal(_("indirect function call requires a simple scalar value")); + t1 = force_string(t1); if (t1->stlen > 0) { /* retrieve function definition node */ @@ -42,8 +42,8 @@ static void free_bcpool(INSTRUCTION *pl); static AWK_CONTEXT *curr_ctxt = NULL; static int ctxt_level; -static NODE *global_table, *param_table, *func_table; -NODE *symbol_table; +static NODE *global_table, *param_table; +NODE *symbol_table, *func_table; /* Use a flag to avoid a strcmp() call inside install() */ static bool installing_specials = false; @@ -108,7 +108,7 @@ lookup(const char *name) if (tables[i]->table_size == 0) continue; - if (do_posix && tables[i] == global_table) + if ((do_posix || do_traditional) && tables[i] == global_table) continue; n = in_array(tables[i], tmp); @@ -451,6 +451,7 @@ void release_all_vars() { assoc_clear(symbol_table); + assoc_clear(func_table); assoc_clear(global_table); } |