diff options
-rw-r--r-- | doc/ChangeLog | 5 | ||||
-rw-r--r-- | doc/gawk.info | 687 | ||||
-rw-r--r-- | doc/gawk.texi | 23 | ||||
-rw-r--r-- | doc/gawktexi.in | 23 | ||||
-rw-r--r-- | extension/ChangeLog | 9 | ||||
-rw-r--r-- | extension/ordchr.c | 2 | ||||
-rw-r--r-- | test/ChangeLog | 4 | ||||
-rw-r--r-- | test/ordchr.awk | 1 | ||||
-rw-r--r-- | test/ordchr.ok | 1 |
9 files changed, 420 insertions, 335 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog index e3d16092..939f43f9 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2021-10-01 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in: Clarify typeof() usage with array elements + created by reference. + 2021-09-27 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in: Small cleanups from Antonio Columbo. General diff --git a/doc/gawk.info b/doc/gawk.info index f8193175..1169d3da 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -14550,6 +14550,23 @@ function causes it to become a scalar variable (unassigned). However, 'isarray()' and 'typeof()' are different; they do not change their arguments from untyped to unassigned. + By "variable" we mean one denoted by a simple identifier. Array +elements that come into existence simply by referencing them are +different, they are automatically forced to be scalars. Consider: + + $ gawk 'BEGIN { print typeof(x) }' + -| untyped + $ gawk 'BEGIN { print typeof(x["foo"]) }' + -| unassigned + +'x[0]' comes into existence before it is passed to 'typeof()'; +'typeof()' cannot tell that it didn't exist prior to being called. +(d.c.) + + This may change in a future release, whereby 'gawk' would allow such +an unassigned array element to be used for a multidimensional array, and +not remain a scalar forever (or until deleted). + File: gawk.info, Node: I18N Functions, Prev: Type Functions, Up: Built-in @@ -36147,6 +36164,8 @@ Index (line 179) * dark corner, length() function: String Functions. (line 201) * dark corner, split() function: String Functions. (line 380) +* dark corner, array elements created by reference: Type Functions. + (line 88) * dark corner, parameter name restrictions: Definition Syntax. (line 44) * dark corner <1>: Glossary. (line 266) @@ -38890,340 +38909,340 @@ Ref: table-bitwise-ops605584 Ref: Bitwise Functions-Footnote-1611647 Ref: Bitwise Functions-Footnote-2611820 Node: Type Functions612011 -Node: I18N Functions614965 -Node: User-defined616616 -Node: Definition Syntax617428 -Ref: Definition Syntax-Footnote-1623122 -Node: Function Example623193 -Ref: Function Example-Footnote-1626115 -Node: Function Calling626137 -Node: Calling A Function626725 -Node: Variable Scope627683 -Node: Pass By Value/Reference630677 -Node: Function Caveats633321 -Ref: Function Caveats-Footnote-1635368 -Node: Return Statement635488 -Node: Dynamic Typing638467 -Node: Indirect Calls639397 -Ref: Indirect Calls-Footnote-1649652 -Node: Functions Summary649780 -Node: Library Functions652485 -Ref: Library Functions-Footnote-1656092 -Ref: Library Functions-Footnote-2656235 -Node: Library Names656406 -Ref: Library Names-Footnote-1660073 -Ref: Library Names-Footnote-2660296 -Node: General Functions660382 -Node: Strtonum Function661564 -Node: Assert Function664586 -Node: Round Function667912 -Node: Cliff Random Function669452 -Node: Ordinal Functions670468 -Ref: Ordinal Functions-Footnote-1673531 -Ref: Ordinal Functions-Footnote-2673783 -Node: Join Function673993 -Ref: Join Function-Footnote-1675763 -Node: Getlocaltime Function675963 -Node: Readfile Function679705 -Node: Shell Quoting681682 -Node: Isnumeric Function683110 -Node: Data File Management684498 -Node: Filetrans Function685130 -Node: Rewind Function689226 -Node: File Checking691135 -Ref: File Checking-Footnote-1692469 -Node: Empty Files692670 -Node: Ignoring Assigns694649 -Node: Getopt Function696199 -Ref: Getopt Function-Footnote-1711422 -Node: Passwd Functions711622 -Ref: Passwd Functions-Footnote-1720461 -Node: Group Functions720549 -Ref: Group Functions-Footnote-1728447 -Node: Walking Arrays728654 -Node: Library Functions Summary731662 -Node: Library Exercises733068 -Node: Sample Programs733533 -Node: Running Examples734303 -Node: Clones735031 -Node: Cut Program736255 -Node: Egrep Program746395 -Node: Id Program755396 -Node: Split Program765343 -Ref: Split Program-Footnote-1775236 -Node: Tee Program775409 -Node: Uniq Program778199 -Node: Wc Program785787 -Node: Bytes vs. Characters786174 -Node: Using extensions787722 -Node: wc program788476 -Node: Miscellaneous Programs793341 -Node: Dupword Program794554 -Node: Alarm Program796584 -Node: Translate Program801439 -Ref: Translate Program-Footnote-1806004 -Node: Labels Program806274 -Ref: Labels Program-Footnote-1809625 -Node: Word Sorting809709 -Node: History Sorting813781 -Node: Extract Program816006 -Node: Simple Sed824060 -Node: Igawk Program827134 -Ref: Igawk Program-Footnote-1841465 -Ref: Igawk Program-Footnote-2841667 -Ref: Igawk Program-Footnote-3841789 -Node: Anagram Program841904 -Node: Signature Program844966 -Node: Programs Summary846213 -Node: Programs Exercises847427 -Ref: Programs Exercises-Footnote-1851557 -Node: Advanced Features851643 -Node: Nondecimal Data853774 -Node: Boolean Typed Values855372 -Node: Array Sorting857253 -Node: Controlling Array Traversal857958 -Ref: Controlling Array Traversal-Footnote-1866326 -Node: Array Sorting Functions866444 -Ref: Array Sorting Functions-Footnote-1871818 -Node: Two-way I/O872014 -Ref: Two-way I/O-Footnote-1879740 -Ref: Two-way I/O-Footnote-2879927 -Node: TCP/IP Networking880009 -Node: Profiling883127 -Node: Extension Philosophy892436 -Node: Advanced Features Summary893915 -Node: Internationalization895930 -Node: I18N and L10N897604 -Node: Explaining gettext898291 -Ref: Explaining gettext-Footnote-1904183 -Ref: Explaining gettext-Footnote-2904368 -Node: Programmer i18n904533 -Ref: Programmer i18n-Footnote-1909482 -Node: Translator i18n909531 -Node: String Extraction910325 -Ref: String Extraction-Footnote-1911457 -Node: Printf Ordering911543 -Ref: Printf Ordering-Footnote-1914329 -Node: I18N Portability914393 -Ref: I18N Portability-Footnote-1916849 -Node: I18N Example916912 -Ref: I18N Example-Footnote-1920187 -Ref: I18N Example-Footnote-2920260 -Node: Gawk I18N920369 -Node: I18N Summary921018 -Node: Debugger922359 -Node: Debugging923359 -Node: Debugging Concepts923800 -Node: Debugging Terms925609 -Node: Awk Debugging928184 -Ref: Awk Debugging-Footnote-1929129 -Node: Sample Debugging Session929261 -Node: Debugger Invocation929795 -Node: Finding The Bug931181 -Node: List of Debugger Commands937655 -Node: Breakpoint Control938988 -Node: Debugger Execution Control942682 -Node: Viewing And Changing Data946044 -Node: Execution Stack949585 -Node: Debugger Info951222 -Node: Miscellaneous Debugger Commands955293 -Node: Readline Support960355 -Node: Limitations961251 -Node: Debugging Summary963805 -Node: Namespaces965084 -Node: Global Namespace966195 -Node: Qualified Names967593 -Node: Default Namespace968592 -Node: Changing The Namespace969333 -Node: Naming Rules970947 -Node: Internal Name Management972795 -Node: Namespace Example973837 -Node: Namespace And Features976399 -Node: Namespace Summary977834 -Node: Arbitrary Precision Arithmetic979311 -Node: Computer Arithmetic980798 -Ref: table-numeric-ranges984564 -Ref: table-floating-point-ranges985057 -Ref: Computer Arithmetic-Footnote-1985715 -Node: Math Definitions985772 -Ref: table-ieee-formats988748 -Node: MPFR features989315 -Node: FP Math Caution991033 -Ref: FP Math Caution-Footnote-1992105 -Node: Inexactness of computations992474 -Node: Inexact representation993505 -Node: Comparing FP Values994865 -Node: Errors accumulate996106 -Node: Strange values997562 -Ref: Strange values-Footnote-11000150 -Node: Getting Accuracy1000255 -Node: Try To Round1002965 -Node: Setting precision1003864 -Ref: table-predefined-precision-strings1004561 -Node: Setting the rounding mode1006391 -Ref: table-gawk-rounding-modes1006765 -Ref: Setting the rounding mode-Footnote-11010696 -Node: Arbitrary Precision Integers1010875 -Ref: Arbitrary Precision Integers-Footnote-11014050 -Node: Checking for MPFR1014199 -Node: POSIX Floating Point Problems1015673 -Ref: POSIX Floating Point Problems-Footnote-11019958 -Node: Floating point summary1019996 -Node: Dynamic Extensions1022186 -Node: Extension Intro1023739 -Node: Plugin License1025005 -Node: Extension Mechanism Outline1025802 -Ref: figure-load-extension1026241 -Ref: figure-register-new-function1027806 -Ref: figure-call-new-function1028898 -Node: Extension API Description1030960 -Node: Extension API Functions Introduction1032673 -Ref: table-api-std-headers1034509 -Node: General Data Types1038758 -Ref: General Data Types-Footnote-11047464 -Node: Memory Allocation Functions1047763 -Ref: Memory Allocation Functions-Footnote-11052264 -Node: Constructor Functions1052363 -Node: API Ownership of MPFR and GMP Values1056016 -Node: Registration Functions1057329 -Node: Extension Functions1058029 -Node: Exit Callback Functions1063351 -Node: Extension Version String1064601 -Node: Input Parsers1065264 -Node: Output Wrappers1077985 -Node: Two-way processors1082497 -Node: Printing Messages1084762 -Ref: Printing Messages-Footnote-11085933 -Node: Updating ERRNO1086086 -Node: Requesting Values1086825 -Ref: table-value-types-returned1087562 -Node: Accessing Parameters1088670 -Node: Symbol Table Access1089907 -Node: Symbol table by name1090419 -Ref: Symbol table by name-Footnote-11093444 -Node: Symbol table by cookie1093572 -Ref: Symbol table by cookie-Footnote-11097757 -Node: Cached values1097821 -Ref: Cached values-Footnote-11101357 -Node: Array Manipulation1101510 -Ref: Array Manipulation-Footnote-11102601 -Node: Array Data Types1102638 -Ref: Array Data Types-Footnote-11105296 -Node: Array Functions1105388 -Node: Flattening Arrays1109886 -Node: Creating Arrays1116862 -Node: Redirection API1121629 -Node: Extension API Variables1124462 -Node: Extension Versioning1125173 -Ref: gawk-api-version1125602 -Node: Extension GMP/MPFR Versioning1127333 -Node: Extension API Informational Variables1128961 -Node: Extension API Boilerplate1130034 -Node: Changes from API V11134008 -Node: Finding Extensions1135580 -Node: Extension Example1136139 -Node: Internal File Description1136937 -Node: Internal File Ops1141017 -Ref: Internal File Ops-Footnote-11152367 -Node: Using Internal File Ops1152507 -Ref: Using Internal File Ops-Footnote-11154890 -Node: Extension Samples1155164 -Node: Extension Sample File Functions1156693 -Node: Extension Sample Fnmatch1164342 -Node: Extension Sample Fork1165829 -Node: Extension Sample Inplace1167047 -Node: Extension Sample Ord1170673 -Node: Extension Sample Readdir1171509 -Ref: table-readdir-file-types1172398 -Node: Extension Sample Revout1173465 -Node: Extension Sample Rev2way1174054 -Node: Extension Sample Read write array1174794 -Node: Extension Sample Readfile1176736 -Node: Extension Sample Time1177831 -Node: Extension Sample API Tests1179583 -Node: gawkextlib1180075 -Node: Extension summary1182993 -Node: Extension Exercises1186695 -Node: Language History1187937 -Node: V7/SVR3.11189593 -Node: SVR41191745 -Node: POSIX1193179 -Node: BTL1194560 -Node: POSIX/GNU1195289 -Node: Feature History1201067 -Node: Common Extensions1218242 -Node: Ranges and Locales1219525 -Ref: Ranges and Locales-Footnote-11224141 -Ref: Ranges and Locales-Footnote-21224168 -Ref: Ranges and Locales-Footnote-31224403 -Node: Contributors1224626 -Node: History summary1230623 -Node: Installation1232003 -Node: Gawk Distribution1232947 -Node: Getting1233431 -Node: Extracting1234394 -Node: Distribution contents1236032 -Node: Unix Installation1243174 -Node: Quick Installation1243978 -Node: Compiling with MPFR1246454 -Node: Shell Startup Files1247146 -Node: Additional Configuration Options1248235 -Node: Configuration Philosophy1250550 -Node: Compiling from Git1252946 -Node: Building the Documentation1253501 -Node: Non-Unix Installation1254885 -Node: PC Installation1255345 -Node: PC Binary Installation1256183 -Node: PC Compiling1256618 -Node: PC Using1257735 -Node: Cygwin1261288 -Node: MSYS1262512 -Node: VMS Installation1263114 -Node: VMS Compilation1263833 -Ref: VMS Compilation-Footnote-11265062 -Node: VMS Dynamic Extensions1265120 -Node: VMS Installation Details1266805 -Node: VMS Running1269067 -Node: VMS GNV1273346 -Node: Bugs1274060 -Node: Bug definition1274972 -Node: Bug address1277476 -Node: Usenet1280864 -Node: Performance bugs1281873 -Node: Asking for help1284794 -Node: Maintainers1286756 -Node: Other Versions1287950 -Node: Installation summary1295802 -Node: Notes1297166 -Node: Compatibility Mode1297960 -Node: Additions1298742 -Node: Accessing The Source1299667 -Node: Adding Code1301104 -Node: New Ports1307323 -Node: Derived Files1311698 -Ref: Derived Files-Footnote-11317358 -Ref: Derived Files-Footnote-21317393 -Ref: Derived Files-Footnote-31317991 -Node: Future Extensions1318105 -Node: Implementation Limitations1318763 -Node: Extension Design1319973 -Node: Old Extension Problems1321117 -Ref: Old Extension Problems-Footnote-11322635 -Node: Extension New Mechanism Goals1322692 -Ref: Extension New Mechanism Goals-Footnote-11326056 -Node: Extension Other Design Decisions1326245 -Node: Extension Future Growth1328358 -Node: Notes summary1328964 -Node: Basic Concepts1330122 -Node: Basic High Level1330803 -Ref: figure-general-flow1331085 -Ref: figure-process-flow1331770 -Ref: Basic High Level-Footnote-11335071 -Node: Basic Data Typing1335256 -Node: Glossary1338584 -Node: Copying1370471 -Node: GNU Free Documentation License1408014 -Node: Index1433134 +Node: I18N Functions615621 +Node: User-defined617272 +Node: Definition Syntax618084 +Ref: Definition Syntax-Footnote-1623778 +Node: Function Example623849 +Ref: Function Example-Footnote-1626771 +Node: Function Calling626793 +Node: Calling A Function627381 +Node: Variable Scope628339 +Node: Pass By Value/Reference631333 +Node: Function Caveats633977 +Ref: Function Caveats-Footnote-1636024 +Node: Return Statement636144 +Node: Dynamic Typing639123 +Node: Indirect Calls640053 +Ref: Indirect Calls-Footnote-1650308 +Node: Functions Summary650436 +Node: Library Functions653141 +Ref: Library Functions-Footnote-1656748 +Ref: Library Functions-Footnote-2656891 +Node: Library Names657062 +Ref: Library Names-Footnote-1660729 +Ref: Library Names-Footnote-2660952 +Node: General Functions661038 +Node: Strtonum Function662220 +Node: Assert Function665242 +Node: Round Function668568 +Node: Cliff Random Function670108 +Node: Ordinal Functions671124 +Ref: Ordinal Functions-Footnote-1674187 +Ref: Ordinal Functions-Footnote-2674439 +Node: Join Function674649 +Ref: Join Function-Footnote-1676419 +Node: Getlocaltime Function676619 +Node: Readfile Function680361 +Node: Shell Quoting682338 +Node: Isnumeric Function683766 +Node: Data File Management685154 +Node: Filetrans Function685786 +Node: Rewind Function689882 +Node: File Checking691791 +Ref: File Checking-Footnote-1693125 +Node: Empty Files693326 +Node: Ignoring Assigns695305 +Node: Getopt Function696855 +Ref: Getopt Function-Footnote-1712078 +Node: Passwd Functions712278 +Ref: Passwd Functions-Footnote-1721117 +Node: Group Functions721205 +Ref: Group Functions-Footnote-1729103 +Node: Walking Arrays729310 +Node: Library Functions Summary732318 +Node: Library Exercises733724 +Node: Sample Programs734189 +Node: Running Examples734959 +Node: Clones735687 +Node: Cut Program736911 +Node: Egrep Program747051 +Node: Id Program756052 +Node: Split Program765999 +Ref: Split Program-Footnote-1775892 +Node: Tee Program776065 +Node: Uniq Program778855 +Node: Wc Program786443 +Node: Bytes vs. Characters786830 +Node: Using extensions788378 +Node: wc program789132 +Node: Miscellaneous Programs793997 +Node: Dupword Program795210 +Node: Alarm Program797240 +Node: Translate Program802095 +Ref: Translate Program-Footnote-1806660 +Node: Labels Program806930 +Ref: Labels Program-Footnote-1810281 +Node: Word Sorting810365 +Node: History Sorting814437 +Node: Extract Program816662 +Node: Simple Sed824716 +Node: Igawk Program827790 +Ref: Igawk Program-Footnote-1842121 +Ref: Igawk Program-Footnote-2842323 +Ref: Igawk Program-Footnote-3842445 +Node: Anagram Program842560 +Node: Signature Program845622 +Node: Programs Summary846869 +Node: Programs Exercises848083 +Ref: Programs Exercises-Footnote-1852213 +Node: Advanced Features852299 +Node: Nondecimal Data854430 +Node: Boolean Typed Values856028 +Node: Array Sorting857909 +Node: Controlling Array Traversal858614 +Ref: Controlling Array Traversal-Footnote-1866982 +Node: Array Sorting Functions867100 +Ref: Array Sorting Functions-Footnote-1872474 +Node: Two-way I/O872670 +Ref: Two-way I/O-Footnote-1880396 +Ref: Two-way I/O-Footnote-2880583 +Node: TCP/IP Networking880665 +Node: Profiling883783 +Node: Extension Philosophy893092 +Node: Advanced Features Summary894571 +Node: Internationalization896586 +Node: I18N and L10N898260 +Node: Explaining gettext898947 +Ref: Explaining gettext-Footnote-1904839 +Ref: Explaining gettext-Footnote-2905024 +Node: Programmer i18n905189 +Ref: Programmer i18n-Footnote-1910138 +Node: Translator i18n910187 +Node: String Extraction910981 +Ref: String Extraction-Footnote-1912113 +Node: Printf Ordering912199 +Ref: Printf Ordering-Footnote-1914985 +Node: I18N Portability915049 +Ref: I18N Portability-Footnote-1917505 +Node: I18N Example917568 +Ref: I18N Example-Footnote-1920843 +Ref: I18N Example-Footnote-2920916 +Node: Gawk I18N921025 +Node: I18N Summary921674 +Node: Debugger923015 +Node: Debugging924015 +Node: Debugging Concepts924456 +Node: Debugging Terms926265 +Node: Awk Debugging928840 +Ref: Awk Debugging-Footnote-1929785 +Node: Sample Debugging Session929917 +Node: Debugger Invocation930451 +Node: Finding The Bug931837 +Node: List of Debugger Commands938311 +Node: Breakpoint Control939644 +Node: Debugger Execution Control943338 +Node: Viewing And Changing Data946700 +Node: Execution Stack950241 +Node: Debugger Info951878 +Node: Miscellaneous Debugger Commands955949 +Node: Readline Support961011 +Node: Limitations961907 +Node: Debugging Summary964461 +Node: Namespaces965740 +Node: Global Namespace966851 +Node: Qualified Names968249 +Node: Default Namespace969248 +Node: Changing The Namespace969989 +Node: Naming Rules971603 +Node: Internal Name Management973451 +Node: Namespace Example974493 +Node: Namespace And Features977055 +Node: Namespace Summary978490 +Node: Arbitrary Precision Arithmetic979967 +Node: Computer Arithmetic981454 +Ref: table-numeric-ranges985220 +Ref: table-floating-point-ranges985713 +Ref: Computer Arithmetic-Footnote-1986371 +Node: Math Definitions986428 +Ref: table-ieee-formats989404 +Node: MPFR features989971 +Node: FP Math Caution991689 +Ref: FP Math Caution-Footnote-1992761 +Node: Inexactness of computations993130 +Node: Inexact representation994161 +Node: Comparing FP Values995521 +Node: Errors accumulate996762 +Node: Strange values998218 +Ref: Strange values-Footnote-11000806 +Node: Getting Accuracy1000911 +Node: Try To Round1003621 +Node: Setting precision1004520 +Ref: table-predefined-precision-strings1005217 +Node: Setting the rounding mode1007047 +Ref: table-gawk-rounding-modes1007421 +Ref: Setting the rounding mode-Footnote-11011352 +Node: Arbitrary Precision Integers1011531 +Ref: Arbitrary Precision Integers-Footnote-11014706 +Node: Checking for MPFR1014855 +Node: POSIX Floating Point Problems1016329 +Ref: POSIX Floating Point Problems-Footnote-11020614 +Node: Floating point summary1020652 +Node: Dynamic Extensions1022842 +Node: Extension Intro1024395 +Node: Plugin License1025661 +Node: Extension Mechanism Outline1026458 +Ref: figure-load-extension1026897 +Ref: figure-register-new-function1028462 +Ref: figure-call-new-function1029554 +Node: Extension API Description1031616 +Node: Extension API Functions Introduction1033329 +Ref: table-api-std-headers1035165 +Node: General Data Types1039414 +Ref: General Data Types-Footnote-11048120 +Node: Memory Allocation Functions1048419 +Ref: Memory Allocation Functions-Footnote-11052920 +Node: Constructor Functions1053019 +Node: API Ownership of MPFR and GMP Values1056672 +Node: Registration Functions1057985 +Node: Extension Functions1058685 +Node: Exit Callback Functions1064007 +Node: Extension Version String1065257 +Node: Input Parsers1065920 +Node: Output Wrappers1078641 +Node: Two-way processors1083153 +Node: Printing Messages1085418 +Ref: Printing Messages-Footnote-11086589 +Node: Updating ERRNO1086742 +Node: Requesting Values1087481 +Ref: table-value-types-returned1088218 +Node: Accessing Parameters1089326 +Node: Symbol Table Access1090563 +Node: Symbol table by name1091075 +Ref: Symbol table by name-Footnote-11094100 +Node: Symbol table by cookie1094228 +Ref: Symbol table by cookie-Footnote-11098413 +Node: Cached values1098477 +Ref: Cached values-Footnote-11102013 +Node: Array Manipulation1102166 +Ref: Array Manipulation-Footnote-11103257 +Node: Array Data Types1103294 +Ref: Array Data Types-Footnote-11105952 +Node: Array Functions1106044 +Node: Flattening Arrays1110542 +Node: Creating Arrays1117518 +Node: Redirection API1122285 +Node: Extension API Variables1125118 +Node: Extension Versioning1125829 +Ref: gawk-api-version1126258 +Node: Extension GMP/MPFR Versioning1127989 +Node: Extension API Informational Variables1129617 +Node: Extension API Boilerplate1130690 +Node: Changes from API V11134664 +Node: Finding Extensions1136236 +Node: Extension Example1136795 +Node: Internal File Description1137593 +Node: Internal File Ops1141673 +Ref: Internal File Ops-Footnote-11153023 +Node: Using Internal File Ops1153163 +Ref: Using Internal File Ops-Footnote-11155546 +Node: Extension Samples1155820 +Node: Extension Sample File Functions1157349 +Node: Extension Sample Fnmatch1164998 +Node: Extension Sample Fork1166485 +Node: Extension Sample Inplace1167703 +Node: Extension Sample Ord1171329 +Node: Extension Sample Readdir1172165 +Ref: table-readdir-file-types1173054 +Node: Extension Sample Revout1174121 +Node: Extension Sample Rev2way1174710 +Node: Extension Sample Read write array1175450 +Node: Extension Sample Readfile1177392 +Node: Extension Sample Time1178487 +Node: Extension Sample API Tests1180239 +Node: gawkextlib1180731 +Node: Extension summary1183649 +Node: Extension Exercises1187351 +Node: Language History1188593 +Node: V7/SVR3.11190249 +Node: SVR41192401 +Node: POSIX1193835 +Node: BTL1195216 +Node: POSIX/GNU1195945 +Node: Feature History1201723 +Node: Common Extensions1218898 +Node: Ranges and Locales1220181 +Ref: Ranges and Locales-Footnote-11224797 +Ref: Ranges and Locales-Footnote-21224824 +Ref: Ranges and Locales-Footnote-31225059 +Node: Contributors1225282 +Node: History summary1231279 +Node: Installation1232659 +Node: Gawk Distribution1233603 +Node: Getting1234087 +Node: Extracting1235050 +Node: Distribution contents1236688 +Node: Unix Installation1243830 +Node: Quick Installation1244634 +Node: Compiling with MPFR1247110 +Node: Shell Startup Files1247802 +Node: Additional Configuration Options1248891 +Node: Configuration Philosophy1251206 +Node: Compiling from Git1253602 +Node: Building the Documentation1254157 +Node: Non-Unix Installation1255541 +Node: PC Installation1256001 +Node: PC Binary Installation1256839 +Node: PC Compiling1257274 +Node: PC Using1258391 +Node: Cygwin1261944 +Node: MSYS1263168 +Node: VMS Installation1263770 +Node: VMS Compilation1264489 +Ref: VMS Compilation-Footnote-11265718 +Node: VMS Dynamic Extensions1265776 +Node: VMS Installation Details1267461 +Node: VMS Running1269723 +Node: VMS GNV1274002 +Node: Bugs1274716 +Node: Bug definition1275628 +Node: Bug address1278132 +Node: Usenet1281520 +Node: Performance bugs1282529 +Node: Asking for help1285450 +Node: Maintainers1287412 +Node: Other Versions1288606 +Node: Installation summary1296458 +Node: Notes1297822 +Node: Compatibility Mode1298616 +Node: Additions1299398 +Node: Accessing The Source1300323 +Node: Adding Code1301760 +Node: New Ports1307979 +Node: Derived Files1312354 +Ref: Derived Files-Footnote-11318014 +Ref: Derived Files-Footnote-21318049 +Ref: Derived Files-Footnote-31318647 +Node: Future Extensions1318761 +Node: Implementation Limitations1319419 +Node: Extension Design1320629 +Node: Old Extension Problems1321773 +Ref: Old Extension Problems-Footnote-11323291 +Node: Extension New Mechanism Goals1323348 +Ref: Extension New Mechanism Goals-Footnote-11326712 +Node: Extension Other Design Decisions1326901 +Node: Extension Future Growth1329014 +Node: Notes summary1329620 +Node: Basic Concepts1330778 +Node: Basic High Level1331459 +Ref: figure-general-flow1331741 +Ref: figure-process-flow1332426 +Ref: Basic High Level-Footnote-11335727 +Node: Basic Data Typing1335912 +Node: Glossary1339240 +Node: Copying1371127 +Node: GNU Free Documentation License1408670 +Node: Index1433790 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index ec7afb8d..349abd15 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -21052,6 +21052,29 @@ function causes it to become a scalar variable (unassigned). However, @code{isarray()} and @code{typeof()} are different; they do not change their arguments from untyped to unassigned. +@cindex dark corner @subentry array elements created by reference +By ``variable'' we mean one denoted by a simple identifier. Array elements +that come into existence simply by referencing them +are different, they are automatically forced to be scalars. Consider: + +@example +$ @kbd{gawk 'BEGIN @{ print typeof(x) @}'} +@print{} untyped +$ @kbd{gawk 'BEGIN @{ print typeof(x["foo"]) @}'} +@print{} unassigned +@end example + +@noindent +@code{x[0]} comes into existence before it is passed to @code{typeof()}; +@code{typeof()} cannot tell that it didn't exist prior to being called. +@value{DARKCORNER} + +@c FIXME: For 5.2, this will change, update this bit of doc. +This may change in a future release, whereby @command{gawk} +would allow such an unassigned array element to be used for +a multidimensional array, and not remain a scalar forever +(or until deleted). + @node I18N Functions @subsection String-Translation Functions @cindex @command{gawk} @subentry string-translation functions diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 110e090c..abe5a236 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -19964,6 +19964,29 @@ function causes it to become a scalar variable (unassigned). However, @code{isarray()} and @code{typeof()} are different; they do not change their arguments from untyped to unassigned. +@cindex dark corner @subentry array elements created by reference +By ``variable'' we mean one denoted by a simple identifier. Array elements +that come into existence simply by referencing them +are different, they are automatically forced to be scalars. Consider: + +@example +$ @kbd{gawk 'BEGIN @{ print typeof(x) @}'} +@print{} untyped +$ @kbd{gawk 'BEGIN @{ print typeof(x["foo"]) @}'} +@print{} unassigned +@end example + +@noindent +@code{x[0]} comes into existence before it is passed to @code{typeof()}; +@code{typeof()} cannot tell that it didn't exist prior to being called. +@value{DARKCORNER} + +@c FIXME: For 5.2, this will change, update this bit of doc. +This may change in a future release, whereby @command{gawk} +would allow such an unassigned array element to be used for +a multidimensional array, and not remain a scalar forever +(or until deleted). + @node I18N Functions @subsection String-Translation Functions @cindex @command{gawk} @subentry string-translation functions diff --git a/extension/ChangeLog b/extension/ChangeLog index 82d2ac1b..ee4ff404 100644 --- a/extension/ChangeLog +++ b/extension/ChangeLog @@ -1,3 +1,12 @@ +2021-09-27 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * ordchr.c (do_ord): Add white space around cast. + +2021-09-27 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * ordchr.c (do_ord): Need to cast to unsigned char to avoid returning + negative values. + 2021-09-22 Arnold D. Robbins <arnold@skeeve.com> * configure.ac: Update version to 5.1.1 in preparation for release. diff --git a/extension/ordchr.c b/extension/ordchr.c index e1afade5..ff990b6b 100644 --- a/extension/ordchr.c +++ b/extension/ordchr.c @@ -67,7 +67,7 @@ do_ord(int nargs, awk_value_t *result, struct awk_ext_func *unused) assert(result != NULL); if (get_argument(0, AWK_STRING, & str)) { - ret = str.str_value.str[0]; + ret = (unsigned char) str.str_value.str[0]; } else if (do_lint) lintwarn(ext_id, _("ord: first argument is not a string")); diff --git a/test/ChangeLog b/test/ChangeLog index f84c8eb8..98b5622a 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2021-09-27 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * ordchr.awk, ordchr.awk: Add test for ord signedness. + 2021-09-19 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (EXTRA_DIST): Remove commas.in from the list. diff --git a/test/ordchr.awk b/test/ordchr.awk index 0295105e..5d6ffe9f 100644 --- a/test/ordchr.awk +++ b/test/ordchr.awk @@ -7,4 +7,5 @@ BEGIN { # test if type conversion between strings and numbers is working properly print chr(ord(0)) print ord(chr("65")) + print ord(chr("159")) } diff --git a/test/ordchr.ok b/test/ordchr.ok index 86d901e9..be3997c6 100644 --- a/test/ordchr.ok +++ b/test/ordchr.ok @@ -3,3 +3,4 @@ A 65 0 65 +159 |