diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2015-06-26 12:46:54 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2015-06-26 12:46:54 +0300 |
commit | 8a4905be350313d41f6c0b20497809760d7fa84e (patch) | |
tree | 0169eb762b2175202db1c9cd889a2b2bc8bbb4bc | |
parent | 0a2de15cba710ff67107bc340950515e1a29edb5 (diff) | |
download | egawk-8a4905be350313d41f6c0b20497809760d7fa84e.tar.gz egawk-8a4905be350313d41f6c0b20497809760d7fa84e.tar.bz2 egawk-8a4905be350313d41f6c0b20497809760d7fa84e.zip |
Improve values returned by typeof. Fix tests and doc.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | builtin.c | 12 | ||||
-rw-r--r-- | doc/ChangeLog | 4 | ||||
-rw-r--r-- | doc/gawk.info | 633 | ||||
-rw-r--r-- | doc/gawk.texi | 35 | ||||
-rw-r--r-- | doc/gawktexi.in | 35 | ||||
-rw-r--r-- | test/ChangeLog | 5 | ||||
-rw-r--r-- | test/dbugtypedre1.ok | 6 | ||||
-rw-r--r-- | test/typedregex1.awk | 2 | ||||
-rw-r--r-- | test/typeof1.ok | 6 | ||||
-rw-r--r-- | test/typeof3.ok | 6 |
11 files changed, 424 insertions, 326 deletions
@@ -10,6 +10,12 @@ * eval.c (Node_old_ext_funci, Op_old_ext_func): Remove from tables. * interpret.h (interpret): Remove stuff for old extensions. + Unrelated: + + * builtin.c (do_typeof): Add support for strnum, distinguish + untyped from unassigned, use "string" and "number". Thanks to + Hermann Peifer for suggesting inclusion of strnum. + 2015-06-25 Arnold D. Robbins <arnold@skeeve.com> Further work straightening out memory management for typeof. @@ -3891,11 +3891,13 @@ do_typeof(int nargs) case Node_val: case Node_var: if (arg == Nnull_string) - res = "untyped"; - else if ((arg->flags & STRING) != 0) - res = "scalar_s"; - else if ((arg->flags & NUMBER) != 0) - res = "scalar_n"; + res = "unassigned"; + else if ((arg->flags & STRING) != 0) { + res = "string"; + if ((arg->flags & MAYBE_NUM) != 0) + res = "strnum"; + } else if ((arg->flags & NUMBER) != 0) + res = "number"; break; case Node_var_new: res = "untyped"; diff --git a/doc/ChangeLog b/doc/ChangeLog index 8c0f151d..d4e8ad23 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2015-06-26 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in: Update description of values returned by typeof. + 2015-06-19 Arnold D. Robbins <arnold@skeeve.com> * gawkinet.info: Fix an old arnold@gnu.org. diff --git a/doc/gawk.info b/doc/gawk.info index 6d6def4f..5b756d9e 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -13516,14 +13516,37 @@ contexts. X is a strongly typed regexp (*note Strong Regexp Constants::). - '"scalar_n"' + '"number"' X is a number. - '"scalar_s"' + '"string"' X is a string. + '"strnum"' + X is a string that might be a number, such as a field or the + result of calling 'split()'. (I.e., X has the STRNUM + attribute; *note Variable Typing::.) + + '"unassigned"' + X is a scalar variable that has not been assigned a value yet. + For example: + + BEGIN { + a[1] # creates a[1] but it has no assigned value + print typeof(a[1]) # scalar_u + } + '"untyped"' - X has not yet been given a type. + X has not yet been used yet at all; it can become a scalar or + an array. For example: + + BEGIN { + print typeof(x) # x never used --> untyped + mk_arr(x) + print typeof(x) # x now an array --> array + } + + function mk_arr(a) { a[1] = 1 } 'isarray()' is meant for use in two circumstances. The first is when traversing a multidimensional array: you can test if an element is @@ -35244,307 +35267,307 @@ Node: Bitwise Functions567560 Ref: table-bitwise-ops568154 Ref: Bitwise Functions-Footnote-1572492 Node: Type Functions572665 -Node: I18N Functions574527 -Node: User-defined576178 -Node: Definition Syntax576983 -Ref: Definition Syntax-Footnote-1582670 -Node: Function Example582741 -Ref: Function Example-Footnote-1585663 -Node: Function Caveats585685 -Node: Calling A Function586203 -Node: Variable Scope587161 -Node: Pass By Value/Reference590155 -Node: Return Statement593654 -Node: Dynamic Typing596633 -Node: Indirect Calls597563 -Ref: Indirect Calls-Footnote-1607814 -Node: Functions Summary607942 -Node: Library Functions610647 -Ref: Library Functions-Footnote-1614256 -Ref: Library Functions-Footnote-2614399 -Node: Library Names614570 -Ref: Library Names-Footnote-1618031 -Ref: Library Names-Footnote-2618254 -Node: General Functions618340 -Node: Strtonum Function619443 -Node: Assert Function622465 -Node: Round Function625791 -Node: Cliff Random Function627332 -Node: Ordinal Functions628348 -Ref: Ordinal Functions-Footnote-1631411 -Ref: Ordinal Functions-Footnote-2631663 -Node: Join Function631873 -Ref: Join Function-Footnote-1633643 -Node: Getlocaltime Function633843 -Node: Readfile Function637587 -Node: Shell Quoting639561 -Node: Data File Management640962 -Node: Filetrans Function641594 -Node: Rewind Function645691 -Node: File Checking647077 -Ref: File Checking-Footnote-1648411 -Node: Empty Files648612 -Node: Ignoring Assigns650591 -Node: Getopt Function652141 -Ref: Getopt Function-Footnote-1663611 -Node: Passwd Functions663811 -Ref: Passwd Functions-Footnote-1672652 -Node: Group Functions672740 -Ref: Group Functions-Footnote-1680639 -Node: Walking Arrays680846 -Node: Library Functions Summary683856 -Node: Library Exercises685262 -Node: Sample Programs685727 -Node: Running Examples686497 -Node: Clones687225 -Node: Cut Program688449 -Node: Egrep Program698170 -Ref: Egrep Program-Footnote-1705682 -Node: Id Program705792 -Node: Split Program709472 -Ref: Split Program-Footnote-1712931 -Node: Tee Program713060 -Node: Uniq Program715850 -Node: Wc Program723276 -Ref: Wc Program-Footnote-1727531 -Node: Miscellaneous Programs727625 -Node: Dupword Program728838 -Node: Alarm Program730868 -Node: Translate Program735723 -Ref: Translate Program-Footnote-1740288 -Node: Labels Program740558 -Ref: Labels Program-Footnote-1743909 -Node: Word Sorting743993 -Node: History Sorting748065 -Node: Extract Program749900 -Node: Simple Sed757431 -Node: Igawk Program760505 -Ref: Igawk Program-Footnote-1774836 -Ref: Igawk Program-Footnote-2775038 -Ref: Igawk Program-Footnote-3775160 -Node: Anagram Program775275 -Node: Signature Program778337 -Node: Programs Summary779584 -Node: Programs Exercises780799 -Ref: Programs Exercises-Footnote-1784928 -Node: Advanced Features785019 -Node: Nondecimal Data787009 -Node: Array Sorting788600 -Node: Controlling Array Traversal789300 -Ref: Controlling Array Traversal-Footnote-1797669 -Node: Array Sorting Functions797787 -Ref: Array Sorting Functions-Footnote-1801674 -Node: Two-way I/O801870 -Ref: Two-way I/O-Footnote-1806821 -Ref: Two-way I/O-Footnote-2807008 -Node: TCP/IP Networking807090 -Node: Profiling809997 -Node: Advanced Features Summary818268 -Node: Internationalization820204 -Node: I18N and L10N821684 -Node: Explaining gettext822371 -Ref: Explaining gettext-Footnote-1827394 -Ref: Explaining gettext-Footnote-2827579 -Node: Programmer i18n827744 -Ref: Programmer i18n-Footnote-1832600 -Node: Translator i18n832649 -Node: String Extraction833443 -Ref: String Extraction-Footnote-1834576 -Node: Printf Ordering834662 -Ref: Printf Ordering-Footnote-1837448 -Node: I18N Portability837512 -Ref: I18N Portability-Footnote-1839968 -Node: I18N Example840031 -Ref: I18N Example-Footnote-1842837 -Node: Gawk I18N842910 -Node: I18N Summary843555 -Node: Debugger844896 -Node: Debugging845918 -Node: Debugging Concepts846359 -Node: Debugging Terms848168 -Node: Awk Debugging850743 -Node: Sample Debugging Session851649 -Node: Debugger Invocation852183 -Node: Finding The Bug853569 -Node: List of Debugger Commands860047 -Node: Breakpoint Control861380 -Node: Debugger Execution Control865074 -Node: Viewing And Changing Data868436 -Node: Execution Stack871810 -Node: Debugger Info873447 -Node: Miscellaneous Debugger Commands877518 -Node: Readline Support882527 -Node: Limitations883423 -Node: Debugging Summary885532 -Node: Arbitrary Precision Arithmetic886705 -Node: Computer Arithmetic888121 -Ref: table-numeric-ranges891712 -Ref: Computer Arithmetic-Footnote-1892434 -Node: Math Definitions892491 -Ref: table-ieee-formats895805 -Ref: Math Definitions-Footnote-1896408 -Node: MPFR features896513 -Node: FP Math Caution898186 -Ref: FP Math Caution-Footnote-1899258 -Node: Inexactness of computations899627 -Node: Inexact representation900587 -Node: Comparing FP Values901947 -Node: Errors accumulate903029 -Node: Getting Accuracy904462 -Node: Try To Round907172 -Node: Setting precision908071 -Ref: table-predefined-precision-strings908768 -Node: Setting the rounding mode910598 -Ref: table-gawk-rounding-modes910972 -Ref: Setting the rounding mode-Footnote-1914380 -Node: Arbitrary Precision Integers914559 -Ref: Arbitrary Precision Integers-Footnote-1919476 -Node: POSIX Floating Point Problems919625 -Ref: POSIX Floating Point Problems-Footnote-1923507 -Node: Floating point summary923545 -Node: Dynamic Extensions925735 -Node: Extension Intro927288 -Node: Plugin License928554 -Node: Extension Mechanism Outline929351 -Ref: figure-load-extension929790 -Ref: figure-register-new-function931355 -Ref: figure-call-new-function932447 -Node: Extension API Description934510 -Node: Extension API Functions Introduction936044 -Node: General Data Types940903 -Ref: General Data Types-Footnote-1946858 -Node: Memory Allocation Functions947157 -Ref: Memory Allocation Functions-Footnote-1950002 -Node: Constructor Functions950101 -Node: Registration Functions951846 -Node: Extension Functions952531 -Node: Exit Callback Functions954830 -Node: Extension Version String956080 -Node: Input Parsers956743 -Node: Output Wrappers966628 -Node: Two-way processors971140 -Node: Printing Messages973404 -Ref: Printing Messages-Footnote-1974480 -Node: Updating 'ERRNO'974633 -Node: Requesting Values975374 -Ref: table-value-types-returned976113 -Node: Accessing Parameters976996 -Node: Symbol Table Access978232 -Node: Symbol table by name978744 -Node: Symbol table by cookie980765 -Ref: Symbol table by cookie-Footnote-1984914 -Node: Cached values984978 -Ref: Cached values-Footnote-1988479 -Node: Array Manipulation988570 -Ref: Array Manipulation-Footnote-1989661 -Node: Array Data Types989698 -Ref: Array Data Types-Footnote-1992356 -Node: Array Functions992448 -Node: Flattening Arrays996307 -Node: Creating Arrays1003215 -Node: Redirection API1007987 -Node: Extension API Variables1010818 -Node: Extension Versioning1011451 -Node: Extension API Informational Variables1013342 -Node: Extension API Boilerplate1014406 -Node: Finding Extensions1018220 -Node: Extension Example1018780 -Node: Internal File Description1019578 -Node: Internal File Ops1023658 -Ref: Internal File Ops-Footnote-11035420 -Node: Using Internal File Ops1035560 -Ref: Using Internal File Ops-Footnote-11037943 -Node: Extension Samples1038218 -Node: Extension Sample File Functions1039747 -Node: Extension Sample Fnmatch1047396 -Node: Extension Sample Fork1048883 -Node: Extension Sample Inplace1050101 -Node: Extension Sample Ord1053311 -Node: Extension Sample Readdir1054147 -Ref: table-readdir-file-types1055036 -Node: Extension Sample Revout1055841 -Node: Extension Sample Rev2way1056430 -Node: Extension Sample Read write array1057170 -Node: Extension Sample Readfile1059112 -Node: Extension Sample Time1060207 -Node: Extension Sample API Tests1061555 -Node: gawkextlib1062047 -Node: Extension summary1064494 -Node: Extension Exercises1068186 -Node: Language History1069683 -Node: V7/SVR3.11071339 -Node: SVR41073492 -Node: POSIX1074926 -Node: BTL1076306 -Node: POSIX/GNU1077036 -Node: Feature History1082875 -Node: Common Extensions1097194 -Node: Ranges and Locales1098477 -Ref: Ranges and Locales-Footnote-11103093 -Ref: Ranges and Locales-Footnote-21103120 -Ref: Ranges and Locales-Footnote-31103355 -Node: Contributors1103576 -Node: History summary1109145 -Node: Installation1110525 -Node: Gawk Distribution1111470 -Node: Getting1111954 -Node: Extracting1112777 -Node: Distribution contents1114415 -Node: Unix Installation1120511 -Node: Quick Installation1121193 -Node: Shell Startup Files1123607 -Node: Additional Configuration Options1124685 -Node: Configuration Philosophy1126490 -Node: Non-Unix Installation1128860 -Node: PC Installation1129318 -Node: PC Binary Installation1130638 -Node: PC Compiling1132490 -Ref: PC Compiling-Footnote-11135514 -Node: PC Testing1135623 -Node: PC Using1136803 -Node: Cygwin1140917 -Node: MSYS1141687 -Node: VMS Installation1142188 -Node: VMS Compilation1142979 -Ref: VMS Compilation-Footnote-11144209 -Node: VMS Dynamic Extensions1144267 -Node: VMS Installation Details1145952 -Node: VMS Running1148205 -Node: VMS GNV1151046 -Node: VMS Old Gawk1151781 -Node: Bugs1152252 -Node: Other Versions1156366 -Node: Installation summary1162840 -Node: Notes1163898 -Node: Compatibility Mode1164763 -Node: Additions1165545 -Node: Accessing The Source1166470 -Node: Adding Code1167906 -Node: New Ports1174061 -Node: Derived Files1178549 -Ref: Derived Files-Footnote-11184034 -Ref: Derived Files-Footnote-21184069 -Ref: Derived Files-Footnote-31184667 -Node: Future Extensions1184781 -Node: Implementation Limitations1185439 -Node: Extension Design1186622 -Node: Old Extension Problems1187776 -Ref: Old Extension Problems-Footnote-11189294 -Node: Extension New Mechanism Goals1189351 -Ref: Extension New Mechanism Goals-Footnote-11192715 -Node: Extension Other Design Decisions1192904 -Node: Extension Future Growth1195017 -Node: Old Extension Mechanism1195853 -Node: Notes summary1197616 -Node: Basic Concepts1198798 -Node: Basic High Level1199479 -Ref: figure-general-flow1199761 -Ref: figure-process-flow1200446 -Ref: Basic High Level-Footnote-11203747 -Node: Basic Data Typing1203932 -Node: Glossary1207260 -Node: Copying1239206 -Node: GNU Free Documentation License1276745 -Node: Index1301863 +Node: I18N Functions575326 +Node: User-defined576977 +Node: Definition Syntax577782 +Ref: Definition Syntax-Footnote-1583469 +Node: Function Example583540 +Ref: Function Example-Footnote-1586462 +Node: Function Caveats586484 +Node: Calling A Function587002 +Node: Variable Scope587960 +Node: Pass By Value/Reference590954 +Node: Return Statement594453 +Node: Dynamic Typing597432 +Node: Indirect Calls598362 +Ref: Indirect Calls-Footnote-1608613 +Node: Functions Summary608741 +Node: Library Functions611446 +Ref: Library Functions-Footnote-1615055 +Ref: Library Functions-Footnote-2615198 +Node: Library Names615369 +Ref: Library Names-Footnote-1618830 +Ref: Library Names-Footnote-2619053 +Node: General Functions619139 +Node: Strtonum Function620242 +Node: Assert Function623264 +Node: Round Function626590 +Node: Cliff Random Function628131 +Node: Ordinal Functions629147 +Ref: Ordinal Functions-Footnote-1632210 +Ref: Ordinal Functions-Footnote-2632462 +Node: Join Function632672 +Ref: Join Function-Footnote-1634442 +Node: Getlocaltime Function634642 +Node: Readfile Function638386 +Node: Shell Quoting640360 +Node: Data File Management641761 +Node: Filetrans Function642393 +Node: Rewind Function646490 +Node: File Checking647876 +Ref: File Checking-Footnote-1649210 +Node: Empty Files649411 +Node: Ignoring Assigns651390 +Node: Getopt Function652940 +Ref: Getopt Function-Footnote-1664410 +Node: Passwd Functions664610 +Ref: Passwd Functions-Footnote-1673451 +Node: Group Functions673539 +Ref: Group Functions-Footnote-1681438 +Node: Walking Arrays681645 +Node: Library Functions Summary684655 +Node: Library Exercises686061 +Node: Sample Programs686526 +Node: Running Examples687296 +Node: Clones688024 +Node: Cut Program689248 +Node: Egrep Program698969 +Ref: Egrep Program-Footnote-1706481 +Node: Id Program706591 +Node: Split Program710271 +Ref: Split Program-Footnote-1713730 +Node: Tee Program713859 +Node: Uniq Program716649 +Node: Wc Program724075 +Ref: Wc Program-Footnote-1728330 +Node: Miscellaneous Programs728424 +Node: Dupword Program729637 +Node: Alarm Program731667 +Node: Translate Program736522 +Ref: Translate Program-Footnote-1741087 +Node: Labels Program741357 +Ref: Labels Program-Footnote-1744708 +Node: Word Sorting744792 +Node: History Sorting748864 +Node: Extract Program750699 +Node: Simple Sed758230 +Node: Igawk Program761304 +Ref: Igawk Program-Footnote-1775635 +Ref: Igawk Program-Footnote-2775837 +Ref: Igawk Program-Footnote-3775959 +Node: Anagram Program776074 +Node: Signature Program779136 +Node: Programs Summary780383 +Node: Programs Exercises781598 +Ref: Programs Exercises-Footnote-1785727 +Node: Advanced Features785818 +Node: Nondecimal Data787808 +Node: Array Sorting789399 +Node: Controlling Array Traversal790099 +Ref: Controlling Array Traversal-Footnote-1798468 +Node: Array Sorting Functions798586 +Ref: Array Sorting Functions-Footnote-1802473 +Node: Two-way I/O802669 +Ref: Two-way I/O-Footnote-1807620 +Ref: Two-way I/O-Footnote-2807807 +Node: TCP/IP Networking807889 +Node: Profiling810796 +Node: Advanced Features Summary819067 +Node: Internationalization821003 +Node: I18N and L10N822483 +Node: Explaining gettext823170 +Ref: Explaining gettext-Footnote-1828193 +Ref: Explaining gettext-Footnote-2828378 +Node: Programmer i18n828543 +Ref: Programmer i18n-Footnote-1833399 +Node: Translator i18n833448 +Node: String Extraction834242 +Ref: String Extraction-Footnote-1835375 +Node: Printf Ordering835461 +Ref: Printf Ordering-Footnote-1838247 +Node: I18N Portability838311 +Ref: I18N Portability-Footnote-1840767 +Node: I18N Example840830 +Ref: I18N Example-Footnote-1843636 +Node: Gawk I18N843709 +Node: I18N Summary844354 +Node: Debugger845695 +Node: Debugging846717 +Node: Debugging Concepts847158 +Node: Debugging Terms848967 +Node: Awk Debugging851542 +Node: Sample Debugging Session852448 +Node: Debugger Invocation852982 +Node: Finding The Bug854368 +Node: List of Debugger Commands860846 +Node: Breakpoint Control862179 +Node: Debugger Execution Control865873 +Node: Viewing And Changing Data869235 +Node: Execution Stack872609 +Node: Debugger Info874246 +Node: Miscellaneous Debugger Commands878317 +Node: Readline Support883326 +Node: Limitations884222 +Node: Debugging Summary886331 +Node: Arbitrary Precision Arithmetic887504 +Node: Computer Arithmetic888920 +Ref: table-numeric-ranges892511 +Ref: Computer Arithmetic-Footnote-1893233 +Node: Math Definitions893290 +Ref: table-ieee-formats896604 +Ref: Math Definitions-Footnote-1897207 +Node: MPFR features897312 +Node: FP Math Caution898985 +Ref: FP Math Caution-Footnote-1900057 +Node: Inexactness of computations900426 +Node: Inexact representation901386 +Node: Comparing FP Values902746 +Node: Errors accumulate903828 +Node: Getting Accuracy905261 +Node: Try To Round907971 +Node: Setting precision908870 +Ref: table-predefined-precision-strings909567 +Node: Setting the rounding mode911397 +Ref: table-gawk-rounding-modes911771 +Ref: Setting the rounding mode-Footnote-1915179 +Node: Arbitrary Precision Integers915358 +Ref: Arbitrary Precision Integers-Footnote-1920275 +Node: POSIX Floating Point Problems920424 +Ref: POSIX Floating Point Problems-Footnote-1924306 +Node: Floating point summary924344 +Node: Dynamic Extensions926534 +Node: Extension Intro928087 +Node: Plugin License929353 +Node: Extension Mechanism Outline930150 +Ref: figure-load-extension930589 +Ref: figure-register-new-function932154 +Ref: figure-call-new-function933246 +Node: Extension API Description935309 +Node: Extension API Functions Introduction936843 +Node: General Data Types941702 +Ref: General Data Types-Footnote-1947657 +Node: Memory Allocation Functions947956 +Ref: Memory Allocation Functions-Footnote-1950801 +Node: Constructor Functions950900 +Node: Registration Functions952645 +Node: Extension Functions953330 +Node: Exit Callback Functions955629 +Node: Extension Version String956879 +Node: Input Parsers957542 +Node: Output Wrappers967427 +Node: Two-way processors971939 +Node: Printing Messages974203 +Ref: Printing Messages-Footnote-1975279 +Node: Updating 'ERRNO'975432 +Node: Requesting Values976173 +Ref: table-value-types-returned976912 +Node: Accessing Parameters977795 +Node: Symbol Table Access979031 +Node: Symbol table by name979543 +Node: Symbol table by cookie981564 +Ref: Symbol table by cookie-Footnote-1985713 +Node: Cached values985777 +Ref: Cached values-Footnote-1989278 +Node: Array Manipulation989369 +Ref: Array Manipulation-Footnote-1990460 +Node: Array Data Types990497 +Ref: Array Data Types-Footnote-1993155 +Node: Array Functions993247 +Node: Flattening Arrays997106 +Node: Creating Arrays1004014 +Node: Redirection API1008786 +Node: Extension API Variables1011617 +Node: Extension Versioning1012250 +Node: Extension API Informational Variables1014141 +Node: Extension API Boilerplate1015205 +Node: Finding Extensions1019019 +Node: Extension Example1019579 +Node: Internal File Description1020377 +Node: Internal File Ops1024457 +Ref: Internal File Ops-Footnote-11036219 +Node: Using Internal File Ops1036359 +Ref: Using Internal File Ops-Footnote-11038742 +Node: Extension Samples1039017 +Node: Extension Sample File Functions1040546 +Node: Extension Sample Fnmatch1048195 +Node: Extension Sample Fork1049682 +Node: Extension Sample Inplace1050900 +Node: Extension Sample Ord1054110 +Node: Extension Sample Readdir1054946 +Ref: table-readdir-file-types1055835 +Node: Extension Sample Revout1056640 +Node: Extension Sample Rev2way1057229 +Node: Extension Sample Read write array1057969 +Node: Extension Sample Readfile1059911 +Node: Extension Sample Time1061006 +Node: Extension Sample API Tests1062354 +Node: gawkextlib1062846 +Node: Extension summary1065293 +Node: Extension Exercises1068985 +Node: Language History1070482 +Node: V7/SVR3.11072138 +Node: SVR41074291 +Node: POSIX1075725 +Node: BTL1077105 +Node: POSIX/GNU1077835 +Node: Feature History1083674 +Node: Common Extensions1097993 +Node: Ranges and Locales1099276 +Ref: Ranges and Locales-Footnote-11103892 +Ref: Ranges and Locales-Footnote-21103919 +Ref: Ranges and Locales-Footnote-31104154 +Node: Contributors1104375 +Node: History summary1109944 +Node: Installation1111324 +Node: Gawk Distribution1112269 +Node: Getting1112753 +Node: Extracting1113576 +Node: Distribution contents1115214 +Node: Unix Installation1121310 +Node: Quick Installation1121992 +Node: Shell Startup Files1124406 +Node: Additional Configuration Options1125484 +Node: Configuration Philosophy1127289 +Node: Non-Unix Installation1129659 +Node: PC Installation1130117 +Node: PC Binary Installation1131437 +Node: PC Compiling1133289 +Ref: PC Compiling-Footnote-11136313 +Node: PC Testing1136422 +Node: PC Using1137602 +Node: Cygwin1141716 +Node: MSYS1142486 +Node: VMS Installation1142987 +Node: VMS Compilation1143778 +Ref: VMS Compilation-Footnote-11145008 +Node: VMS Dynamic Extensions1145066 +Node: VMS Installation Details1146751 +Node: VMS Running1149004 +Node: VMS GNV1151845 +Node: VMS Old Gawk1152580 +Node: Bugs1153051 +Node: Other Versions1157165 +Node: Installation summary1163639 +Node: Notes1164697 +Node: Compatibility Mode1165562 +Node: Additions1166344 +Node: Accessing The Source1167269 +Node: Adding Code1168705 +Node: New Ports1174860 +Node: Derived Files1179348 +Ref: Derived Files-Footnote-11184833 +Ref: Derived Files-Footnote-21184868 +Ref: Derived Files-Footnote-31185466 +Node: Future Extensions1185580 +Node: Implementation Limitations1186238 +Node: Extension Design1187421 +Node: Old Extension Problems1188575 +Ref: Old Extension Problems-Footnote-11190093 +Node: Extension New Mechanism Goals1190150 +Ref: Extension New Mechanism Goals-Footnote-11193514 +Node: Extension Other Design Decisions1193703 +Node: Extension Future Growth1195816 +Node: Old Extension Mechanism1196652 +Node: Notes summary1198415 +Node: Basic Concepts1199597 +Node: Basic High Level1200278 +Ref: figure-general-flow1200560 +Ref: figure-process-flow1201245 +Ref: Basic High Level-Footnote-11204546 +Node: Basic Data Typing1204731 +Node: Glossary1208059 +Node: Copying1240005 +Node: GNU Free Documentation License1277544 +Node: Index1302662 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 7552f164..64f494a0 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -19503,14 +19503,43 @@ Return one of the following strings, depending upon the type of @var{x}: @item "regexp" @var{x} is a strongly typed regexp (@pxref{Strong Regexp Constants}). -@item "scalar_n" +@item "number" @var{x} is a number. -@item "scalar_s" +@item "string" @var{x} is a string. +@item "strnum" +@var{x} is a string that might be a number, such as a field or +the result of calling @code{split()}. (I.e., @var{x} has the STRNUM +attribute; @pxref{Variable Typing}.) + +@item "unassigned" +@var{x} is a scalar variable that has not been assigned a value yet. +For example: + +@example +BEGIN @{ + a[1] # creates a[1] but it has no assigned value + print typeof(a[1]) # scalar_u +@} +@end example + @item "untyped" -@var{x} has not yet been given a type. +@var{x} has not yet been used yet at all; it can become a scalar or an +array. +For example: + +@example +BEGIN @{ + print typeof(x) # x never used --> untyped + mk_arr(x) + print typeof(x) # x now an array --> array +@} + +function mk_arr(a) @{ a[1] = 1 @} +@end example + @end table @end table diff --git a/doc/gawktexi.in b/doc/gawktexi.in index e02cd568..81ff1aec 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -18624,14 +18624,43 @@ Return one of the following strings, depending upon the type of @var{x}: @item "regexp" @var{x} is a strongly typed regexp (@pxref{Strong Regexp Constants}). -@item "scalar_n" +@item "number" @var{x} is a number. -@item "scalar_s" +@item "string" @var{x} is a string. +@item "strnum" +@var{x} is a string that might be a number, such as a field or +the result of calling @code{split()}. (I.e., @var{x} has the STRNUM +attribute; @pxref{Variable Typing}.) + +@item "unassigned" +@var{x} is a scalar variable that has not been assigned a value yet. +For example: + +@example +BEGIN @{ + a[1] # creates a[1] but it has no assigned value + print typeof(a[1]) # scalar_u +@} +@end example + @item "untyped" -@var{x} has not yet been given a type. +@var{x} has not yet been used yet at all; it can become a scalar or an +array. +For example: + +@example +BEGIN @{ + print typeof(x) # x never used --> untyped + mk_arr(x) + print typeof(x) # x now an array --> array +@} + +function mk_arr(a) @{ a[1] = 1 @} +@end example + @end table @end table diff --git a/test/ChangeLog b/test/ChangeLog index 6b88e287..b121fbec 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -14,6 +14,11 @@ * Makefile.am (getfile, dbugtypedre1, dbugtypedre2): Fixed to work if building out of the source tree. + Unrelated: + + * dbugtypedre1.ok, typedregex1.awk, typeof1.ok, typeof3.ok: + Update after code changes. + 2015-06-25 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (negtime): Fix out-of-tree test run. diff --git a/test/dbugtypedre1.ok b/test/dbugtypedre1.ok index de3c8bcd..dffee0e8 100644 --- a/test/dbugtypedre1.ok +++ b/test/dbugtypedre1.ok @@ -1,10 +1,10 @@ Watchpoint 1: e Starting program: -scalar_n +number untyped regexp -scalar_s -array scalar_n +string +array number Stopping in BEGIN ... Watchpoint 1: e Old value: untyped variable diff --git a/test/typedregex1.awk b/test/typedregex1.awk index fc8ba805..f308a335 100644 --- a/test/typedregex1.awk +++ b/test/typedregex1.awk @@ -69,7 +69,7 @@ function simple_tests( fbre, numresult, strresult) else print "conversion to number: fail" - if (typeof(fbre) == "scalar_n") + if (typeof(fbre) == "number") print "typeof variable after conversion: ok" else print "typeof variable after conversion: fail" diff --git a/test/typeof1.ok b/test/typeof1.ok index 3a2f6a92..132cc24e 100644 --- a/test/typeof1.ok +++ b/test/typeof1.ok @@ -1,7 +1,7 @@ -scalar_n +number untyped regexp -scalar_s -array scalar_n +string +array number regexp regexp diff --git a/test/typeof3.ok b/test/typeof3.ok index 8186ad9e..a6cd6c4a 100644 --- a/test/typeof3.ok +++ b/test/typeof3.ok @@ -1,9 +1,9 @@ regexp xx regexp -scalar_n +number 4 -scalar_n -untyped +number +unassigned gawk: typeof3.awk:18: fatal: attempt to use scalar `a["1"]' as an array EXIT CODE: 2 |