diff options
-rw-r--r-- | ChangeLog | 27 | ||||
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | awk.h | 6 | ||||
-rw-r--r-- | awkgram.c | 6 | ||||
-rw-r--r-- | awkgram.y | 6 | ||||
-rw-r--r-- | builtin.c | 14 | ||||
-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-- | eval.c | 2 | ||||
-rw-r--r-- | ext.c | 147 | ||||
-rw-r--r-- | interpret.h | 20 | ||||
-rw-r--r-- | test/ChangeLog | 27 | ||||
-rw-r--r-- | test/Makefile.am | 27 | ||||
-rw-r--r-- | test/Makefile.in | 32 | ||||
-rw-r--r-- | test/Maketests | 5 | ||||
-rw-r--r-- | test/dbugtypedre1.awk (renamed from test/dbugtypedre.awk) | 0 | ||||
-rw-r--r-- | test/dbugtypedre1.in (renamed from test/dbugtypedre.in) | 0 | ||||
-rw-r--r-- | test/dbugtypedre1.ok (renamed from test/dbugtypedre.ok) | 6 | ||||
-rw-r--r-- | test/dbugtypedre2.awk | 1 | ||||
-rw-r--r-- | test/dbugtypedre2.in | 4 | ||||
-rw-r--r-- | test/dbugtypedre2.ok | 15 | ||||
-rw-r--r-- | test/getfile.ok | 8 | ||||
-rw-r--r-- | test/id.ok | 1 | ||||
-rw-r--r-- | test/typedregex1.awk | 2 | ||||
-rw-r--r-- | test/typedregex2.awk | 11 | ||||
-rw-r--r-- | test/typedregex2.ok | 4 | ||||
-rw-r--r-- | test/typeof1.ok | 6 | ||||
-rw-r--r-- | test/typeof3.ok | 6 |
30 files changed, 569 insertions, 524 deletions
@@ -1,3 +1,30 @@ +2015-06-28 Arnold D. Robbins <arnold@skeeve.com> + + Improve memory tracking of typed regexps. + + * awkgram.y (make_regnode): Set valref to 1. + * interpret.h (r_interpret): Have Op_push_re upref typed regexp. + * builtin.c (do_typeof): OK to deref typed regex. + * awk.h (force_string): Do dupnode on the regexp text. + +2015-06-26 Arnold D. Robbins <arnold@skeeve.com> + + Remove support for old-style extensions. + + * awk.h (Node_old_ext_func, Op_old_ext_func): Removed. + Remove all uses throughout the code. + (load_old_ext, make_old_builtin): Remove declarations. + * ext.c (load_old_ext, make_old_builtin): Removed. + * awkgram.y (tokentab): Remove "extension" entry. + * 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. @@ -64,6 +64,9 @@ Changes from 4.1.x to 4.2.0 array element is an array, regexp, string or number. The isarray() function is deprecated in favor of typeof(). +16. As promised when 4.1 was released, the old extension mechanism, + using the `extension' function, is now gone. + Changes from 4.1.2 to 4.1.3 --------------------------- @@ -286,7 +286,6 @@ typedef enum nodevals { Node_param_list, /* lnode is a variable, rnode is more list */ Node_func, /* lnode is param. list, rnode is body */ Node_ext_func, /* extension function, code_ptr is builtin code */ - Node_old_ext_func, /* extension function, code_ptr is builtin code */ Node_builtin_func, /* built-in function, main use is for FUNCTAB */ Node_array_ref, /* array passed by ref as parameter */ @@ -634,7 +633,6 @@ typedef enum opcodeval { Op_builtin, Op_sub_builtin, /* sub, gsub and gensub */ Op_ext_builtin, - Op_old_ext_builtin, /* temporary */ Op_in_array, /* boolean test of membership in array */ /* function call instruction */ @@ -1426,10 +1424,8 @@ extern NODE **r_get_field(NODE *n, Func_ptr *assign, bool reference); /* ext.c */ extern NODE *do_ext(int nargs); void load_ext(const char *lib_name); /* temporary */ -extern NODE *load_old_ext(SRCFILE *s, const char *init_func, const char *fini_func, NODE *obj); extern void close_extensions(void); #ifdef DYNAMIC -extern void make_old_builtin(const char *, NODE *(*)(int), int); extern awk_bool_t make_builtin(const awk_ext_func_t *); extern NODE *get_argument(int); extern NODE *get_actual_argument(int, bool, bool); @@ -1768,7 +1764,7 @@ static inline NODE * force_string(NODE *s) { if (s->type == Node_typedregex) - return s->re_exp; + return dupnode(s->re_exp); if ((s->flags & STRCUR) != 0 && (s->stfmt == -1 || s->stfmt == CONVFMTidx) @@ -3953,7 +3953,7 @@ regular_print: if (! at_seen) { n = lookup((yyvsp[-3])->func_name); if (n != NULL && n->type != Node_func - && n->type != Node_ext_func && n->type != Node_old_ext_func) { + && n->type != Node_ext_func) { error_ln((yyvsp[-3])->source_line, _("attempt to use non-function `%s' in function call"), (yyvsp[-3])->func_name); @@ -4475,9 +4475,6 @@ static const struct token tokentab[] = { {"eval", Op_symbol, LEX_EVAL, 0, 0, 0}, {"exit", Op_K_exit, LEX_EXIT, 0, 0, 0}, {"exp", Op_builtin, LEX_BUILTIN, A(1), do_exp, MPF(exp)}, -#ifdef DYNAMIC -{"extension", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3), do_ext, 0}, -#endif {"fflush", Op_builtin, LEX_BUILTIN, A(0)|A(1), do_fflush, 0}, {"for", Op_K_for, LEX_FOR, BREAK|CONTINUE, 0, 0}, {"func", Op_func, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0, 0}, @@ -7289,6 +7286,7 @@ make_regnode(int type, NODE *exp) } n->re_exp = exp; n->re_flags = CONSTANT; + n->valref = 1; } return n; } @@ -1809,7 +1809,7 @@ direct_func_call if (! at_seen) { n = lookup($1->func_name); if (n != NULL && n->type != Node_func - && n->type != Node_ext_func && n->type != Node_old_ext_func) { + && n->type != Node_ext_func) { error_ln($1->source_line, _("attempt to use non-function `%s' in function call"), $1->func_name); @@ -2055,9 +2055,6 @@ static const struct token tokentab[] = { {"eval", Op_symbol, LEX_EVAL, 0, 0, 0}, {"exit", Op_K_exit, LEX_EXIT, 0, 0, 0}, {"exp", Op_builtin, LEX_BUILTIN, A(1), do_exp, MPF(exp)}, -#ifdef DYNAMIC -{"extension", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3), do_ext, 0}, -#endif {"fflush", Op_builtin, LEX_BUILTIN, A(0)|A(1), do_fflush, 0}, {"for", Op_K_for, LEX_FOR, BREAK|CONTINUE, 0, 0}, {"func", Op_func, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0, 0}, @@ -4869,6 +4866,7 @@ make_regnode(int type, NODE *exp) } n->re_exp = exp; n->re_flags = CONSTANT; + n->valref = 1; } return n; } @@ -3884,18 +3884,18 @@ do_typeof(int nargs) deref = false; break; case Node_typedregex: - /* Op_push_re does not UPREF */ res = "regexp"; - deref = false; break; 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 @@ -241,7 +241,6 @@ static const char *const nodetypes[] = { "Node_param_list", "Node_func", "Node_ext_func", - "Node_old_ext_func", "Node_builtin_func", "Node_array_ref", "Node_array_tree", @@ -332,7 +331,6 @@ static struct optypetab { { "Op_builtin", NULL }, { "Op_sub_builtin", NULL }, { "Op_ext_builtin", NULL }, - { "Op_old_ext_builtin", NULL }, /* temporary */ { "Op_in_array", " in " }, { "Op_func_call", NULL }, { "Op_indirect_func_call", NULL }, @@ -32,9 +32,6 @@ extern SRCFILE *srcfiles; #ifdef DYNAMIC -#define OLD_INIT_FUNC "dlload" -#define OLD_FINI_FUNC "dlunload" - #include <dlfcn.h> /* @@ -91,95 +88,6 @@ load_ext(const char *lib_name) lib_name, INIT_FUNC); } -/* do_ext --- load an extension at run-time: interface to load_ext */ - -NODE * -do_ext(int nargs) -{ - NODE *obj, *init = NULL, *fini = NULL, *ret = NULL; - SRCFILE *s; - char *init_func = NULL; - char *fini_func = NULL; - - if (nargs == 3) { - fini = POP_STRING(); - fini_func = fini->stptr; - } - if (nargs >= 2) { - init = POP_STRING(); - init_func = init->stptr; - } - obj = POP_STRING(); - - s = add_srcfile(SRC_EXTLIB, obj->stptr, srcfiles, NULL, NULL); - if (s != NULL) - ret = load_old_ext(s, init_func, fini_func, obj); - - DEREF(obj); - if (fini != NULL) - DEREF(fini); - if (init != NULL) - DEREF(init); - if (ret == NULL) - ret = dupnode(Nnull_string); - return ret; -} - -/* load_old_ext --- load an external library */ - -NODE * -load_old_ext(SRCFILE *s, const char *init_func, const char *fini_func, NODE *obj) -{ - NODE *(*func)(NODE *, void *); - NODE *tmp; - void *dl; - int flags = RTLD_LAZY; - int *gpl_compat; - const char *lib_name = s->fullpath; - - if (init_func == NULL || init_func[0] == '\0') - init_func = OLD_INIT_FUNC; - - if (fini_func == NULL || fini_func[0] == '\0') - fini_func = OLD_FINI_FUNC; - - if (do_sandbox) - fatal(_("extensions are not allowed in sandbox mode")); - - if (do_traditional || do_posix) - fatal(_("`extension' is a gawk extension")); - - if (lib_name == NULL) - fatal(_("extension: received NULL lib_name")); - - if ((dl = dlopen(lib_name, flags)) == NULL) - fatal(_("extension: cannot open library `%s' (%s)"), lib_name, - dlerror()); - - /* Per the GNU Coding standards */ - gpl_compat = (int *) dlsym(dl, "plugin_is_GPL_compatible"); - if (gpl_compat == NULL) - fatal(_("extension: library `%s': does not define `plugin_is_GPL_compatible' (%s)"), - lib_name, dlerror()); - func = (NODE *(*)(NODE *, void *)) dlsym(dl, init_func); - if (func == NULL) - fatal(_("extension: library `%s': cannot call function `%s' (%s)"), - lib_name, init_func, dlerror()); - - if (obj == NULL) { - obj = make_string(lib_name, strlen(lib_name)); - tmp = (*func)(obj, dl); - unref(tmp); - unref(obj); - tmp = NULL; - } else - tmp = (*func)(obj, dl); - - s->fini_func = (void (*)(void)) dlsym(dl, fini_func); - return tmp; -} - - /* make_builtin --- register name to be called as func with a builtin body */ awk_bool_t @@ -237,61 +145,6 @@ make_builtin(const awk_ext_func_t *funcinfo) return awk_true; } -/* make_old_builtin --- register name to be called as func with a builtin body */ - -void -make_old_builtin(const char *name, NODE *(*func)(int), int count) /* temporary */ -{ - NODE *symbol, *f; - INSTRUCTION *b; - const char *sp; - char c; - - sp = name; - if (sp == NULL || *sp == '\0') - fatal(_("extension: missing function name")); - - if (! is_letter(*sp)) - fatal(_("extension: illegal character `%c' in function name `%s'"), *sp, name); - - for (sp++; (c = *sp++) != '\0';) { - if (! is_identchar(c)) - fatal(_("extension: illegal character `%c' in function name `%s'"), c, name); - } - - f = lookup(name); - - if (f != NULL) { - if (f->type == Node_func) { - /* user-defined function */ - fatal(_("extension: can't redefine function `%s'"), name); - } else if (f->type == Node_ext_func) { - /* multiple extension() calls etc. */ - if (do_lint) - lintwarn(_("extension: function `%s' already defined"), name); - return; - } else - /* variable name etc. */ - fatal(_("extension: function name `%s' previously defined"), name); - } else if (check_special(name) >= 0) - fatal(_("extension: can't use gawk built-in `%s' as function name"), name); - - if (count < 0) - fatal(_("make_builtin: negative argument count for function `%s'"), - name); - - b = bcalloc(Op_symbol, 1, 0); - b->builtin = func; - b->expr_count = count; - - /* NB: extension sub must return something */ - - symbol = install_symbol(estrdup(name, strlen(name)), Node_old_ext_func); - symbol->code_ptr = b; - track_ext_func(name); -} - - /* get_argument --- get the i'th argument of a dynamically linked function */ NODE * diff --git a/interpret.h b/interpret.h index 1005174a..0a5cbbfe 100644 --- a/interpret.h +++ b/interpret.h @@ -948,7 +948,6 @@ arrayfor: break; case Op_ext_builtin: - case Op_old_ext_builtin: { int arg_count = pc->expr_count; awk_value_t result; @@ -991,6 +990,8 @@ arrayfor: r = POP_STRING(); unref(m->re_exp); m->re_exp = r; + } else if (m->type == Node_typedregex) { + UPREF(m); } PUSH(m); break; @@ -1084,8 +1085,7 @@ match_re: PUSH(r); break; } else if (f->type != Node_func) { - if ( f->type == Node_ext_func - || f->type == Node_old_ext_func) { + if (f->type == Node_ext_func) { /* code copied from below, keep in sync */ INSTRUCTION *bc; char *fname = pc->func_name; @@ -1096,10 +1096,7 @@ match_re: bc = f->code_ptr; assert(bc->opcode == Op_symbol); - if (f->type == Node_ext_func) - npc[0].opcode = Op_ext_builtin; /* self modifying code */ - else - npc[0].opcode = Op_old_ext_builtin; /* self modifying code */ + npc[0].opcode = Op_ext_builtin; /* self modifying code */ npc[0].extfunc = bc->extfunc; npc[0].expr_count = arg_count; /* actual argument count */ npc[1] = pc[1]; @@ -1125,12 +1122,12 @@ match_re: f = pc->func_body; if (f == NULL) { f = lookup(pc->func_name); - if (f == NULL || (f->type != Node_func && f->type != Node_ext_func && f->type != Node_old_ext_func)) + if (f == NULL || (f->type != Node_func && f->type != Node_ext_func)) fatal(_("function `%s' not defined"), pc->func_name); pc->func_body = f; /* save for next call */ } - if (f->type == Node_ext_func || f->type == Node_old_ext_func) { + if (f->type == Node_ext_func) { /* keep in sync with indirect call code */ INSTRUCTION *bc; char *fname = pc->func_name; @@ -1138,10 +1135,7 @@ match_re: bc = f->code_ptr; assert(bc->opcode == Op_symbol); - if (f->type == Node_ext_func) - pc->opcode = Op_ext_builtin; /* self modifying code */ - else - pc->opcode = Op_old_ext_builtin; /* self modifying code */ + pc->opcode = Op_ext_builtin; /* self modifying code */ pc->extfunc = bc->extfunc; pc->expr_count = arg_count; /* actual argument count */ (pc + 1)->func_name = fname; /* name of the builtin */ diff --git a/test/ChangeLog b/test/ChangeLog index b92d8ae7..f29dea72 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,30 @@ +2015-06-28 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am (typedregex2): New test. + * typedregex2.awk, typedregex2.ok: New files. + Thanks to Hermann Peifer for the report. + +2015-06-26 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am (dbugtypedre1): Renamed from dbugtypedre. + (dbugtypedre2): New test. + * dbugtypedre1.awk, dbugtypedre1.in, dbugtypedre1.ok: Renamed files. + * dbugtypedre2.awk, dbugtypedre2.in, dbugtypedre2.ok: New files. + + Unrelated: + + * id.ok: Update after code changes. + + Unrelated: + + * 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/Makefile.am b/test/Makefile.am index 03d28f21..df1f1e2c 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -177,9 +177,12 @@ EXTRA_DIST = \ datanonl.ok \ dbugeval.in \ dbugeval.ok \ - dbugtypedre.awk \ - dbugtypedre.in \ - dbugtypedre.ok \ + dbugtypedre1.awk \ + dbugtypedre1.in \ + dbugtypedre1.ok \ + dbugtypedre2.awk \ + dbugtypedre2.in \ + dbugtypedre2.ok \ defref.awk \ defref.ok \ delargv.awk \ @@ -986,6 +989,8 @@ EXTRA_DIST = \ tweakfld.ok \ typedregex1.awk \ typedregex1.ok \ + typedregex2.awk \ + typedregex2.ok \ typeof1.awk \ typeof1.ok \ typeof2.awk \ @@ -1088,7 +1093,8 @@ UNIX_TESTS = \ GAWK_EXT_TESTS = \ aadelete1 aadelete2 aarray1 aasort aasorti argtest arraysort \ backw badargs beginfile1 beginfile2 binmode1 charasbytes \ - colonwarn clos1way crlf dbugeval dbugtypedre delsub devfd devfd1 devfd2 dumpvars errno exit \ + colonwarn clos1way crlf dbugeval dbugtypedre1 dbugtypedre2 delsub \ + devfd devfd1 devfd2 dumpvars errno exit \ fieldwdth fpat1 fpat2 fpat3 fpat4 fpatnull fsfwfs funlen \ functab1 functab2 functab3 fwtest fwtest2 fwtest3 \ genpot gensub gensub2 getlndir gnuops2 gnuops3 gnureops gsubind \ @@ -1108,7 +1114,7 @@ GAWK_EXT_TESTS = \ splitarg4 strftime \ strtonum switch2 symtab1 symtab2 symtab3 symtab4 symtab5 symtab6 \ symtab7 symtab8 symtab9 \ - typedregex1 typeof1 typeof2 typeof3 typeof4 + typedregex1 typedregex2 typeof1 typeof2 typeof3 typeof4 timeout EXTRA_TESTS = inftest regtest @@ -1996,7 +2002,7 @@ testext:: getfile: @echo $@ - @$(AWK) -v TESTEXT_QUIET=1 -ltestext -f $(srcdir)/$@.awk $(srcdir)/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @AWKPATH="$(srcdir)" $(AWK) -v TESTEXT_QUIET=1 -ltestext -f $@.awk < $(srcdir)/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ readdir: @@ -2135,9 +2141,14 @@ negtime:: @TZ=GMT AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @AWKPATH="$(srcdir)" $(AWK) -f checknegtime.awk "$(srcdir)"/$@.ok _$@ && rm -f _$@ -dbugtypedre: +dbugtypedre1: @echo $@ - @AWKPATH="$(srcdir)" $(AWK) -D -f $@.awk < $@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @AWKPATH="$(srcdir)" $(AWK) -D -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + +dbugtypedre2: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -D -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ # Targets generated for other tests: diff --git a/test/Makefile.in b/test/Makefile.in index 294c60c0..ec270c1b 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -434,9 +434,12 @@ EXTRA_DIST = \ datanonl.ok \ dbugeval.in \ dbugeval.ok \ - dbugtypedre.awk \ - dbugtypedre.in \ - dbugtypedre.ok \ + dbugtypedre1.awk \ + dbugtypedre1.in \ + dbugtypedre1.ok \ + dbugtypedre2.awk \ + dbugtypedre2.in \ + dbugtypedre2.ok \ defref.awk \ defref.ok \ delargv.awk \ @@ -1243,6 +1246,8 @@ EXTRA_DIST = \ tweakfld.ok \ typedregex1.awk \ typedregex1.ok \ + typedregex2.awk \ + typedregex2.ok \ typeof1.awk \ typeof1.ok \ typeof2.awk \ @@ -1344,7 +1349,8 @@ UNIX_TESTS = \ GAWK_EXT_TESTS = \ aadelete1 aadelete2 aarray1 aasort aasorti argtest arraysort \ backw badargs beginfile1 beginfile2 binmode1 charasbytes \ - colonwarn clos1way crlf dbugeval dbugtypedre delsub devfd devfd1 devfd2 dumpvars errno exit \ + colonwarn clos1way crlf dbugeval dbugtypedre1 dbugtypedre2 delsub \ + devfd devfd1 devfd2 dumpvars errno exit \ fieldwdth fpat1 fpat2 fpat3 fpat4 fpatnull fsfwfs funlen \ functab1 functab2 functab3 fwtest fwtest2 fwtest3 \ genpot gensub gensub2 getlndir gnuops2 gnuops3 gnureops gsubind \ @@ -1364,7 +1370,7 @@ GAWK_EXT_TESTS = \ splitarg4 strftime \ strtonum switch2 symtab1 symtab2 symtab3 symtab4 symtab5 symtab6 \ symtab7 symtab8 symtab9 \ - typedregex1 typeof1 typeof2 typeof3 typeof4 + typedregex1 typedregex2 typeof1 typeof2 typeof3 typeof4 EXTRA_TESTS = inftest regtest INET_TESTS = inetdayu inetdayt inetechu inetecht @@ -2433,7 +2439,7 @@ testext:: getfile: @echo $@ - @$(AWK) -v TESTEXT_QUIET=1 -ltestext -f $(srcdir)/$@.awk $(srcdir)/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @AWKPATH="$(srcdir)" $(AWK) -v TESTEXT_QUIET=1 -ltestext -f $@.awk < $(srcdir)/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ readdir: @@ -2571,9 +2577,14 @@ negtime:: @TZ=GMT AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @AWKPATH="$(srcdir)" $(AWK) -f checknegtime.awk "$(srcdir)"/$@.ok _$@ && rm -f _$@ -dbugtypedre: +dbugtypedre1: @echo $@ - @AWKPATH="$(srcdir)" $(AWK) -D -f $@.awk < $@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @AWKPATH="$(srcdir)" $(AWK) -D -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + +dbugtypedre2: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -D -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ Gt-dummy: # file Maketests, generated from Makefile.am by the Gentests program @@ -3914,6 +3925,11 @@ typedregex1: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +typedregex2: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + typeof1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index e4cea0de..462128ea 100644 --- a/test/Maketests +++ b/test/Maketests @@ -1337,6 +1337,11 @@ typedregex1: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +typedregex2: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + typeof1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/dbugtypedre.awk b/test/dbugtypedre1.awk index b8c0b6d7..b8c0b6d7 100644 --- a/test/dbugtypedre.awk +++ b/test/dbugtypedre1.awk diff --git a/test/dbugtypedre.in b/test/dbugtypedre1.in index 00158c65..00158c65 100644 --- a/test/dbugtypedre.in +++ b/test/dbugtypedre1.in diff --git a/test/dbugtypedre.ok b/test/dbugtypedre1.ok index de3c8bcd..dffee0e8 100644 --- a/test/dbugtypedre.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/dbugtypedre2.awk b/test/dbugtypedre2.awk new file mode 100644 index 00000000..a78de32b --- /dev/null +++ b/test/dbugtypedre2.awk @@ -0,0 +1 @@ +BEGIN { x = 0; x = @/[a-z]/; x = "" } diff --git a/test/dbugtypedre2.in b/test/dbugtypedre2.in new file mode 100644 index 00000000..d01ce5a5 --- /dev/null +++ b/test/dbugtypedre2.in @@ -0,0 +1,4 @@ +w x + r + n + n diff --git a/test/dbugtypedre2.ok b/test/dbugtypedre2.ok new file mode 100644 index 00000000..9c04e1e7 --- /dev/null +++ b/test/dbugtypedre2.ok @@ -0,0 +1,15 @@ +Watchpoint 1: x +Starting program: +Stopping in BEGIN ... +Watchpoint 1: x + Old value: untyped variable + New value: 0 +main() at `dbugtypedre2.awk':1 +1 BEGIN { x = 0; x = @/[a-z]/; x = "" } +Watchpoint 1: x + Old value: 0 + New value: @/[a-z]/ +main() at `dbugtypedre2.awk':1 +1 BEGIN { x = 0; x = @/[a-z]/; x = "" } +Program exited normally with exit value: 0 +EXIT CODE: 2 diff --git a/test/getfile.ok b/test/getfile.ok index 92c915f2..1109a303 100644 --- a/test/getfile.ok +++ b/test/getfile.ok @@ -1,16 +1,16 @@ BEGIN -gawk: ./getfile.awk:9: warning: cannot open unrecognized file type `<<' for `echo hello; echo goodbye' +gawk: getfile.awk:9: warning: cannot open unrecognized file type `<<' for `echo hello; echo goodbye' get_file: get_file(echo hello; echo goodbye, <<, -1) failed expected error result 0 get_file returned 1 input_name echo hello; echo goodbye 1 hello -BEGINFILE (getfile.awk) ERRNO () +BEGINFILE (-) ERRNO () get_file returned 1 -input_name getfile.awk +input_name - end BEGIN -ENDFILE (getfile.awk) ERRNO () +ENDFILE (-) ERRNO () END 1 goodbye @@ -57,7 +57,6 @@ an_array -> untyped patsplit -> builtin NR -> scalar SUBSEP -> scalar -extension -> builtin i -> untyped sub -> builtin OFMT -> scalar 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/typedregex2.awk b/test/typedregex2.awk new file mode 100644 index 00000000..e17df4be --- /dev/null +++ b/test/typedregex2.awk @@ -0,0 +1,11 @@ +BEGIN { + x = @/xxx/ + y = @/yyy/ + print typeof(x), typeof(y) + print x, y + + x++ + y = y "" + print typeof(x), typeof(y) + print x, y +} diff --git a/test/typedregex2.ok b/test/typedregex2.ok new file mode 100644 index 00000000..832ef551 --- /dev/null +++ b/test/typedregex2.ok @@ -0,0 +1,4 @@ +regexp regexp +xxx yyy +number string +1 yyy 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 |