diff options
-rw-r--r-- | ChangeLog | 37 | ||||
-rw-r--r-- | awk.h | 5 | ||||
-rw-r--r-- | awkgram.c | 739 | ||||
-rw-r--r-- | awkgram.y | 21 | ||||
-rw-r--r-- | builtin.c | 140 | ||||
-rw-r--r-- | doc/ChangeLog | 5 | ||||
-rw-r--r-- | doc/gawk.info | 588 | ||||
-rw-r--r-- | doc/gawk.texi | 21 | ||||
-rw-r--r-- | doc/gawktexi.in | 21 | ||||
-rw-r--r-- | eval.c | 2 | ||||
-rw-r--r-- | interpret.h | 10 | ||||
-rw-r--r-- | test/ChangeLog | 9 | ||||
-rw-r--r-- | test/Makefile.am | 4 | ||||
-rw-r--r-- | test/Makefile.in | 9 | ||||
-rw-r--r-- | test/Maketests | 5 | ||||
-rw-r--r-- | test/id.ok | 1 | ||||
-rw-r--r-- | test/indirectbuiltin.awk | 371 | ||||
-rw-r--r-- | test/indirectbuiltin.ok | 43 |
18 files changed, 1362 insertions, 669 deletions
@@ -1,8 +1,45 @@ +2015-03-31 Arnold D. Robbins <arnold@skeeve.com> + + * awk.h (call_sub): Renamed from call_sub_func. + (call_match, call_split_func): Declare. + * builtin.c (call_sub): Renamed from call_sub_func. + (call_match, call_split_func): New functions. + * interpret.h (r_interpret): Call new functions as appropriate. + * node.c (r_unref): Revert change to handle Node_regex, not needed. + +2015-03-31 Arnold D. Robbins <arnold@skeeve.com> + + * awk.h (r_get_field): Declare. + * builtin.c (call_sub_func): Rearrange the stack to be what + the buitin function expects. + * eval.c (r_get_field): Make extern. + +2015-03-24 Arnold D. Robbins <arnold@skeeve.com> + + * awkgram.y (make_regnode): Make extern. + * awk.h (make_regnode): Declare. + * builtin.c (call_sub_func): Start on reworking the stack to + be what do_sub() expects. Still needs work. + * interpret.h (r_interpret): Add a cast in comparison with do_sub(). + * node.c (r_unref): Handle Node_regex nodes. + 2015-03-24 Andrew J. Schorr <aschorr@telemetry-investments.com> * interpret.h (r_interpret): When Op_K_exit has an argument of Nnull_string, do not update exit_val, since no value was supplied. +2015-03-20 Arnold D. Robbins <arnold@skeeve.com> + + Start on fixing indirect calls of builtins. + + * awk.h (call_sub_func): Add declaration. + * awkgram.y (lookup_builtin): Handle length, sub functions. + (install_builtin): Handle length function. + * builtin.c (call_sub_func): New function. + * interpret.h (r_interpret): If calling do_sub, do it through + call_sub_func(). +>>>>>>> feature/fix-indirect-call + 2015-03-18 Arnold D. Robbins <arnold@skeeve.com> * config.guess, config.sub: Updated, from libtool 2.4.6. @@ -1331,6 +1331,7 @@ extern void install_builtins(void); extern bool is_alpha(int c); extern bool is_alnum(int c); extern bool is_identchar(int c); +extern NODE *make_regnode(int type, NODE *exp); /* builtin.c */ extern double double_to_int(double d); extern NODE *do_exp(int nargs); @@ -1360,6 +1361,9 @@ extern NODE *do_rand(int nargs); extern NODE *do_srand(int nargs); extern NODE *do_match(int nargs); extern NODE *do_sub(int nargs, unsigned int flags); +extern NODE *call_sub(const char *name, int nargs); +extern NODE *call_match(int nargs); +extern NODE *call_split_func(const char *name, int nargs); extern NODE *format_tree(const char *, size_t, NODE **, long); extern NODE *do_lshift(int nargs); extern NODE *do_rshift(int nargs); @@ -1406,6 +1410,7 @@ extern NODE **r_get_lhs(NODE *n, bool reference); extern STACK_ITEM *grow_stack(void); extern void dump_fcall_stack(FILE *fp); extern int register_exec_hook(Func_pre_exec preh, Func_post_exec posth); +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 */ @@ -113,7 +113,6 @@ static INSTRUCTION *mk_binary(INSTRUCTION *s1, INSTRUCTION *s2, INSTRUCTION *op) static INSTRUCTION *mk_boolean(INSTRUCTION *left, INSTRUCTION *right, INSTRUCTION *op); static INSTRUCTION *mk_assignment(INSTRUCTION *lhs, INSTRUCTION *rhs, INSTRUCTION *op); static INSTRUCTION *mk_getline(INSTRUCTION *op, INSTRUCTION *opt_var, INSTRUCTION *redir, int redirtype); -static NODE *make_regnode(int type, NODE *exp); static int count_expressions(INSTRUCTION **list, bool isarg); static INSTRUCTION *optimize_assignment(INSTRUCTION *exp); static void add_lint(INSTRUCTION *list, LINTTYPE linttype); @@ -192,7 +191,7 @@ extern double fmod(double x, double y); #define YYSTYPE INSTRUCTION * -#line 196 "awkgram.c" /* yacc.c:339 */ +#line 195 "awkgram.c" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus @@ -346,7 +345,7 @@ int yyparse (void); /* Copy the second part of user declarations. */ -#line 350 "awkgram.c" /* yacc.c:358 */ +#line 349 "awkgram.c" /* yacc.c:358 */ #ifdef short # undef short @@ -648,25 +647,25 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 195, 195, 197, 202, 203, 207, 219, 223, 234, - 240, 246, 255, 263, 265, 270, 278, 280, 286, 287, - 289, 315, 326, 337, 343, 352, 362, 364, 366, 372, - 380, 381, 385, 404, 403, 437, 439, 444, 445, 458, - 463, 464, 468, 470, 472, 479, 569, 611, 653, 766, - 773, 780, 790, 799, 808, 817, 828, 844, 843, 867, - 879, 879, 977, 977, 1010, 1040, 1046, 1047, 1053, 1054, - 1061, 1066, 1078, 1092, 1094, 1102, 1107, 1109, 1117, 1119, - 1128, 1129, 1137, 1142, 1142, 1153, 1157, 1165, 1166, 1169, - 1171, 1176, 1177, 1186, 1187, 1192, 1197, 1203, 1205, 1207, - 1214, 1215, 1221, 1222, 1227, 1229, 1234, 1236, 1244, 1249, - 1258, 1265, 1267, 1269, 1285, 1295, 1302, 1304, 1309, 1311, - 1313, 1321, 1323, 1328, 1330, 1335, 1337, 1339, 1389, 1391, - 1393, 1395, 1397, 1399, 1401, 1403, 1417, 1422, 1427, 1452, - 1458, 1460, 1462, 1464, 1466, 1468, 1473, 1477, 1509, 1511, - 1517, 1523, 1536, 1537, 1538, 1543, 1548, 1552, 1556, 1571, - 1584, 1589, 1626, 1655, 1656, 1662, 1663, 1668, 1670, 1677, - 1694, 1711, 1713, 1720, 1725, 1733, 1743, 1755, 1764, 1768, - 1772, 1776, 1780, 1784, 1787, 1789, 1793, 1797, 1801 + 0, 194, 194, 196, 201, 202, 206, 218, 222, 233, + 239, 245, 254, 262, 264, 269, 277, 279, 285, 286, + 288, 314, 325, 336, 342, 351, 361, 363, 365, 371, + 379, 380, 384, 403, 402, 436, 438, 443, 444, 457, + 462, 463, 467, 469, 471, 478, 568, 610, 652, 765, + 772, 779, 789, 798, 807, 816, 827, 843, 842, 866, + 878, 878, 976, 976, 1009, 1039, 1045, 1046, 1052, 1053, + 1060, 1065, 1077, 1091, 1093, 1101, 1106, 1108, 1116, 1118, + 1127, 1128, 1136, 1141, 1141, 1152, 1156, 1164, 1165, 1168, + 1170, 1175, 1176, 1185, 1186, 1191, 1196, 1202, 1204, 1206, + 1213, 1214, 1220, 1221, 1226, 1228, 1233, 1235, 1243, 1248, + 1257, 1264, 1266, 1268, 1284, 1294, 1301, 1303, 1308, 1310, + 1312, 1320, 1322, 1327, 1329, 1334, 1336, 1338, 1388, 1390, + 1392, 1394, 1396, 1398, 1400, 1402, 1416, 1421, 1426, 1451, + 1457, 1459, 1461, 1463, 1465, 1467, 1472, 1476, 1508, 1510, + 1516, 1522, 1535, 1536, 1537, 1542, 1547, 1551, 1555, 1570, + 1583, 1588, 1625, 1654, 1655, 1661, 1662, 1667, 1669, 1676, + 1693, 1710, 1712, 1719, 1724, 1732, 1742, 1754, 1763, 1767, + 1771, 1775, 1779, 1783, 1786, 1788, 1792, 1796, 1800 }; #endif @@ -1839,24 +1838,24 @@ yyreduce: switch (yyn) { case 3: -#line 198 "awkgram.y" /* yacc.c:1646 */ +#line 197 "awkgram.y" /* yacc.c:1646 */ { rule = 0; yyerrok; } -#line 1848 "awkgram.c" /* yacc.c:1646 */ +#line 1847 "awkgram.c" /* yacc.c:1646 */ break; case 5: -#line 204 "awkgram.y" /* yacc.c:1646 */ +#line 203 "awkgram.y" /* yacc.c:1646 */ { next_sourcefile(); } -#line 1856 "awkgram.c" /* yacc.c:1646 */ +#line 1855 "awkgram.c" /* yacc.c:1646 */ break; case 6: -#line 208 "awkgram.y" /* yacc.c:1646 */ +#line 207 "awkgram.y" /* yacc.c:1646 */ { rule = 0; /* @@ -1865,19 +1864,19 @@ yyreduce: */ /* yyerrok; */ } -#line 1869 "awkgram.c" /* yacc.c:1646 */ +#line 1868 "awkgram.c" /* yacc.c:1646 */ break; case 7: -#line 220 "awkgram.y" /* yacc.c:1646 */ +#line 219 "awkgram.y" /* yacc.c:1646 */ { (void) append_rule((yyvsp[-1]), (yyvsp[0])); } -#line 1877 "awkgram.c" /* yacc.c:1646 */ +#line 1876 "awkgram.c" /* yacc.c:1646 */ break; case 8: -#line 224 "awkgram.y" /* yacc.c:1646 */ +#line 223 "awkgram.y" /* yacc.c:1646 */ { if (rule != Rule) { msg(_("%s blocks must have an action part"), ruletab[rule]); @@ -1888,41 +1887,41 @@ yyreduce: } else /* pattern rule with non-empty pattern */ (void) append_rule((yyvsp[-1]), NULL); } -#line 1892 "awkgram.c" /* yacc.c:1646 */ +#line 1891 "awkgram.c" /* yacc.c:1646 */ break; case 9: -#line 235 "awkgram.y" /* yacc.c:1646 */ +#line 234 "awkgram.y" /* yacc.c:1646 */ { in_function = NULL; (void) mk_function((yyvsp[-1]), (yyvsp[0])); yyerrok; } -#line 1902 "awkgram.c" /* yacc.c:1646 */ +#line 1901 "awkgram.c" /* yacc.c:1646 */ break; case 10: -#line 241 "awkgram.y" /* yacc.c:1646 */ +#line 240 "awkgram.y" /* yacc.c:1646 */ { want_source = false; at_seen = false; yyerrok; } -#line 1912 "awkgram.c" /* yacc.c:1646 */ +#line 1911 "awkgram.c" /* yacc.c:1646 */ break; case 11: -#line 247 "awkgram.y" /* yacc.c:1646 */ +#line 246 "awkgram.y" /* yacc.c:1646 */ { want_source = false; at_seen = false; yyerrok; } -#line 1922 "awkgram.c" /* yacc.c:1646 */ +#line 1921 "awkgram.c" /* yacc.c:1646 */ break; case 12: -#line 256 "awkgram.y" /* yacc.c:1646 */ +#line 255 "awkgram.y" /* yacc.c:1646 */ { if (include_source((yyvsp[0])) < 0) YYABORT; @@ -1930,23 +1929,23 @@ yyreduce: bcfree((yyvsp[0])); (yyval) = NULL; } -#line 1934 "awkgram.c" /* yacc.c:1646 */ +#line 1933 "awkgram.c" /* yacc.c:1646 */ break; case 13: -#line 264 "awkgram.y" /* yacc.c:1646 */ +#line 263 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1940 "awkgram.c" /* yacc.c:1646 */ +#line 1939 "awkgram.c" /* yacc.c:1646 */ break; case 14: -#line 266 "awkgram.y" /* yacc.c:1646 */ +#line 265 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1946 "awkgram.c" /* yacc.c:1646 */ +#line 1945 "awkgram.c" /* yacc.c:1646 */ break; case 15: -#line 271 "awkgram.y" /* yacc.c:1646 */ +#line 270 "awkgram.y" /* yacc.c:1646 */ { if (load_library((yyvsp[0])) < 0) YYABORT; @@ -1954,35 +1953,35 @@ yyreduce: bcfree((yyvsp[0])); (yyval) = NULL; } -#line 1958 "awkgram.c" /* yacc.c:1646 */ +#line 1957 "awkgram.c" /* yacc.c:1646 */ break; case 16: -#line 279 "awkgram.y" /* yacc.c:1646 */ +#line 278 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1964 "awkgram.c" /* yacc.c:1646 */ +#line 1963 "awkgram.c" /* yacc.c:1646 */ break; case 17: -#line 281 "awkgram.y" /* yacc.c:1646 */ +#line 280 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1970 "awkgram.c" /* yacc.c:1646 */ +#line 1969 "awkgram.c" /* yacc.c:1646 */ break; case 18: -#line 286 "awkgram.y" /* yacc.c:1646 */ +#line 285 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; rule = Rule; } -#line 1976 "awkgram.c" /* yacc.c:1646 */ +#line 1975 "awkgram.c" /* yacc.c:1646 */ break; case 19: -#line 288 "awkgram.y" /* yacc.c:1646 */ +#line 287 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); rule = Rule; } -#line 1982 "awkgram.c" /* yacc.c:1646 */ +#line 1981 "awkgram.c" /* yacc.c:1646 */ break; case 20: -#line 290 "awkgram.y" /* yacc.c:1646 */ +#line 289 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *tp; @@ -2008,11 +2007,11 @@ yyreduce: (yyval) = list_append(list_merge((yyvsp[-3]), (yyvsp[0])), tp); rule = Rule; } -#line 2012 "awkgram.c" /* yacc.c:1646 */ +#line 2011 "awkgram.c" /* yacc.c:1646 */ break; case 21: -#line 316 "awkgram.y" /* yacc.c:1646 */ +#line 315 "awkgram.y" /* yacc.c:1646 */ { static int begin_seen = 0; if (do_lint_old && ++begin_seen == 2) @@ -2023,11 +2022,11 @@ yyreduce: (yyvsp[0])->source_file = source; (yyval) = (yyvsp[0]); } -#line 2027 "awkgram.c" /* yacc.c:1646 */ +#line 2026 "awkgram.c" /* yacc.c:1646 */ break; case 22: -#line 327 "awkgram.y" /* yacc.c:1646 */ +#line 326 "awkgram.y" /* yacc.c:1646 */ { static int end_seen = 0; if (do_lint_old && ++end_seen == 2) @@ -2038,73 +2037,73 @@ yyreduce: (yyvsp[0])->source_file = source; (yyval) = (yyvsp[0]); } -#line 2042 "awkgram.c" /* yacc.c:1646 */ +#line 2041 "awkgram.c" /* yacc.c:1646 */ break; case 23: -#line 338 "awkgram.y" /* yacc.c:1646 */ +#line 337 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->in_rule = rule = BEGINFILE; (yyvsp[0])->source_file = source; (yyval) = (yyvsp[0]); } -#line 2052 "awkgram.c" /* yacc.c:1646 */ +#line 2051 "awkgram.c" /* yacc.c:1646 */ break; case 24: -#line 344 "awkgram.y" /* yacc.c:1646 */ +#line 343 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->in_rule = rule = ENDFILE; (yyvsp[0])->source_file = source; (yyval) = (yyvsp[0]); } -#line 2062 "awkgram.c" /* yacc.c:1646 */ +#line 2061 "awkgram.c" /* yacc.c:1646 */ break; case 25: -#line 353 "awkgram.y" /* yacc.c:1646 */ +#line 352 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-3]) == NULL) (yyval) = list_create(instruction(Op_no_op)); else (yyval) = (yyvsp[-3]); } -#line 2073 "awkgram.c" /* yacc.c:1646 */ +#line 2072 "awkgram.c" /* yacc.c:1646 */ break; case 26: -#line 363 "awkgram.y" /* yacc.c:1646 */ +#line 362 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2079 "awkgram.c" /* yacc.c:1646 */ +#line 2078 "awkgram.c" /* yacc.c:1646 */ break; case 27: -#line 365 "awkgram.y" /* yacc.c:1646 */ +#line 364 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2085 "awkgram.c" /* yacc.c:1646 */ +#line 2084 "awkgram.c" /* yacc.c:1646 */ break; case 28: -#line 367 "awkgram.y" /* yacc.c:1646 */ +#line 366 "awkgram.y" /* yacc.c:1646 */ { yyerror(_("`%s' is a built-in function, it cannot be redefined"), tokstart); YYABORT; } -#line 2095 "awkgram.c" /* yacc.c:1646 */ +#line 2094 "awkgram.c" /* yacc.c:1646 */ break; case 29: -#line 373 "awkgram.y" /* yacc.c:1646 */ +#line 372 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); at_seen = false; } -#line 2104 "awkgram.c" /* yacc.c:1646 */ +#line 2103 "awkgram.c" /* yacc.c:1646 */ break; case 32: -#line 386 "awkgram.y" /* yacc.c:1646 */ +#line 385 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[-5])->source_file = source; if (install_function((yyvsp[-4])->lextok, (yyvsp[-5]), (yyvsp[-2])) < 0) @@ -2115,17 +2114,17 @@ yyreduce: /* $4 already free'd in install_function */ (yyval) = (yyvsp[-5]); } -#line 2119 "awkgram.c" /* yacc.c:1646 */ +#line 2118 "awkgram.c" /* yacc.c:1646 */ break; case 33: -#line 404 "awkgram.y" /* yacc.c:1646 */ +#line 403 "awkgram.y" /* yacc.c:1646 */ { want_regexp = true; } -#line 2125 "awkgram.c" /* yacc.c:1646 */ +#line 2124 "awkgram.c" /* yacc.c:1646 */ break; case 34: -#line 406 "awkgram.y" /* yacc.c:1646 */ +#line 405 "awkgram.y" /* yacc.c:1646 */ { NODE *n, *exp; char *re; @@ -2154,23 +2153,23 @@ yyreduce: (yyval)->opcode = Op_match_rec; (yyval)->memory = n; } -#line 2158 "awkgram.c" /* yacc.c:1646 */ +#line 2157 "awkgram.c" /* yacc.c:1646 */ break; case 35: -#line 438 "awkgram.y" /* yacc.c:1646 */ +#line 437 "awkgram.y" /* yacc.c:1646 */ { bcfree((yyvsp[0])); } -#line 2164 "awkgram.c" /* yacc.c:1646 */ +#line 2163 "awkgram.c" /* yacc.c:1646 */ break; case 37: -#line 444 "awkgram.y" /* yacc.c:1646 */ +#line 443 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2170 "awkgram.c" /* yacc.c:1646 */ +#line 2169 "awkgram.c" /* yacc.c:1646 */ break; case 38: -#line 446 "awkgram.y" /* yacc.c:1646 */ +#line 445 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[0]) == NULL) (yyval) = (yyvsp[-1]); @@ -2183,40 +2182,40 @@ yyreduce: } yyerrok; } -#line 2187 "awkgram.c" /* yacc.c:1646 */ +#line 2186 "awkgram.c" /* yacc.c:1646 */ break; case 39: -#line 459 "awkgram.y" /* yacc.c:1646 */ +#line 458 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2193 "awkgram.c" /* yacc.c:1646 */ +#line 2192 "awkgram.c" /* yacc.c:1646 */ break; case 42: -#line 469 "awkgram.y" /* yacc.c:1646 */ +#line 468 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2199 "awkgram.c" /* yacc.c:1646 */ +#line 2198 "awkgram.c" /* yacc.c:1646 */ break; case 43: -#line 471 "awkgram.y" /* yacc.c:1646 */ +#line 470 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 2205 "awkgram.c" /* yacc.c:1646 */ +#line 2204 "awkgram.c" /* yacc.c:1646 */ break; case 44: -#line 473 "awkgram.y" /* yacc.c:1646 */ +#line 472 "awkgram.y" /* yacc.c:1646 */ { if (do_pretty_print) (yyval) = list_prepend((yyvsp[0]), instruction(Op_exec_count)); else (yyval) = (yyvsp[0]); } -#line 2216 "awkgram.c" /* yacc.c:1646 */ +#line 2215 "awkgram.c" /* yacc.c:1646 */ break; case 45: -#line 480 "awkgram.y" /* yacc.c:1646 */ +#line 479 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *dflt, *curr = NULL, *cexp, *cstmt; INSTRUCTION *ip, *nextc, *tbreak; @@ -2306,11 +2305,11 @@ yyreduce: break_allowed--; fix_break_continue(ip, tbreak, NULL); } -#line 2310 "awkgram.c" /* yacc.c:1646 */ +#line 2309 "awkgram.c" /* yacc.c:1646 */ break; case 46: -#line 570 "awkgram.y" /* yacc.c:1646 */ +#line 569 "awkgram.y" /* yacc.c:1646 */ { /* * ----------------- @@ -2352,11 +2351,11 @@ yyreduce: continue_allowed--; fix_break_continue(ip, tbreak, tcont); } -#line 2356 "awkgram.c" /* yacc.c:1646 */ +#line 2355 "awkgram.c" /* yacc.c:1646 */ break; case 47: -#line 612 "awkgram.y" /* yacc.c:1646 */ +#line 611 "awkgram.y" /* yacc.c:1646 */ { /* * ----------------- @@ -2398,11 +2397,11 @@ yyreduce: } /* else $1 and $4 are NULLs */ } -#line 2402 "awkgram.c" /* yacc.c:1646 */ +#line 2401 "awkgram.c" /* yacc.c:1646 */ break; case 48: -#line 654 "awkgram.y" /* yacc.c:1646 */ +#line 653 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *ip; char *var_name = (yyvsp[-5])->lextok; @@ -2515,44 +2514,44 @@ regular_loop: break_allowed--; continue_allowed--; } -#line 2519 "awkgram.c" /* yacc.c:1646 */ +#line 2518 "awkgram.c" /* yacc.c:1646 */ break; case 49: -#line 767 "awkgram.y" /* yacc.c:1646 */ +#line 766 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_for_loop((yyvsp[-11]), (yyvsp[-9]), (yyvsp[-6]), (yyvsp[-3]), (yyvsp[0])); break_allowed--; continue_allowed--; } -#line 2530 "awkgram.c" /* yacc.c:1646 */ +#line 2529 "awkgram.c" /* yacc.c:1646 */ break; case 50: -#line 774 "awkgram.y" /* yacc.c:1646 */ +#line 773 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_for_loop((yyvsp[-10]), (yyvsp[-8]), (INSTRUCTION *) NULL, (yyvsp[-3]), (yyvsp[0])); break_allowed--; continue_allowed--; } -#line 2541 "awkgram.c" /* yacc.c:1646 */ +#line 2540 "awkgram.c" /* yacc.c:1646 */ break; case 51: -#line 781 "awkgram.y" /* yacc.c:1646 */ +#line 780 "awkgram.y" /* yacc.c:1646 */ { if (do_pretty_print) (yyval) = list_prepend((yyvsp[0]), instruction(Op_exec_count)); else (yyval) = (yyvsp[0]); } -#line 2552 "awkgram.c" /* yacc.c:1646 */ +#line 2551 "awkgram.c" /* yacc.c:1646 */ break; case 52: -#line 791 "awkgram.y" /* yacc.c:1646 */ +#line 790 "awkgram.y" /* yacc.c:1646 */ { if (! break_allowed) error_ln((yyvsp[-1])->source_line, @@ -2561,11 +2560,11 @@ regular_loop: (yyval) = list_create((yyvsp[-1])); } -#line 2565 "awkgram.c" /* yacc.c:1646 */ +#line 2564 "awkgram.c" /* yacc.c:1646 */ break; case 53: -#line 800 "awkgram.y" /* yacc.c:1646 */ +#line 799 "awkgram.y" /* yacc.c:1646 */ { if (! continue_allowed) error_ln((yyvsp[-1])->source_line, @@ -2574,11 +2573,11 @@ regular_loop: (yyval) = list_create((yyvsp[-1])); } -#line 2578 "awkgram.c" /* yacc.c:1646 */ +#line 2577 "awkgram.c" /* yacc.c:1646 */ break; case 54: -#line 809 "awkgram.y" /* yacc.c:1646 */ +#line 808 "awkgram.y" /* yacc.c:1646 */ { /* if inside function (rule = 0), resolve context at run-time */ if (rule && rule != Rule) @@ -2587,11 +2586,11 @@ regular_loop: (yyvsp[-1])->target_jmp = ip_rec; (yyval) = list_create((yyvsp[-1])); } -#line 2591 "awkgram.c" /* yacc.c:1646 */ +#line 2590 "awkgram.c" /* yacc.c:1646 */ break; case 55: -#line 818 "awkgram.y" /* yacc.c:1646 */ +#line 817 "awkgram.y" /* yacc.c:1646 */ { /* if inside function (rule = 0), resolve context at run-time */ if (rule == BEGIN || rule == END || rule == ENDFILE) @@ -2602,11 +2601,11 @@ regular_loop: (yyvsp[-1])->target_endfile = ip_endfile; (yyval) = list_create((yyvsp[-1])); } -#line 2606 "awkgram.c" /* yacc.c:1646 */ +#line 2605 "awkgram.c" /* yacc.c:1646 */ break; case 56: -#line 829 "awkgram.y" /* yacc.c:1646 */ +#line 828 "awkgram.y" /* yacc.c:1646 */ { /* Initialize the two possible jump targets, the actual target * is resolved at run-time. @@ -2621,20 +2620,20 @@ regular_loop: } else (yyval) = list_append((yyvsp[-1]), (yyvsp[-2])); } -#line 2625 "awkgram.c" /* yacc.c:1646 */ +#line 2624 "awkgram.c" /* yacc.c:1646 */ break; case 57: -#line 844 "awkgram.y" /* yacc.c:1646 */ +#line 843 "awkgram.y" /* yacc.c:1646 */ { if (! in_function) yyerror(_("`return' used outside function context")); } -#line 2634 "awkgram.c" /* yacc.c:1646 */ +#line 2633 "awkgram.c" /* yacc.c:1646 */ break; case 58: -#line 847 "awkgram.y" /* yacc.c:1646 */ +#line 846 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-1]) == NULL) { (yyval) = list_create((yyvsp[-3])); @@ -2655,17 +2654,17 @@ regular_loop: (yyval) = list_append((yyvsp[-1]), (yyvsp[-3])); } } -#line 2659 "awkgram.c" /* yacc.c:1646 */ +#line 2658 "awkgram.c" /* yacc.c:1646 */ break; case 60: -#line 879 "awkgram.y" /* yacc.c:1646 */ +#line 878 "awkgram.y" /* yacc.c:1646 */ { in_print = true; in_parens = 0; } -#line 2665 "awkgram.c" /* yacc.c:1646 */ +#line 2664 "awkgram.c" /* yacc.c:1646 */ break; case 61: -#line 880 "awkgram.y" /* yacc.c:1646 */ +#line 879 "awkgram.y" /* yacc.c:1646 */ { /* * Optimization: plain `print' has no expression list, so $3 is null. @@ -2762,17 +2761,17 @@ regular_print: } } } -#line 2766 "awkgram.c" /* yacc.c:1646 */ +#line 2765 "awkgram.c" /* yacc.c:1646 */ break; case 62: -#line 977 "awkgram.y" /* yacc.c:1646 */ +#line 976 "awkgram.y" /* yacc.c:1646 */ { sub_counter = 0; } -#line 2772 "awkgram.c" /* yacc.c:1646 */ +#line 2771 "awkgram.c" /* yacc.c:1646 */ break; case 63: -#line 978 "awkgram.y" /* yacc.c:1646 */ +#line 977 "awkgram.y" /* yacc.c:1646 */ { char *arr = (yyvsp[-2])->lextok; @@ -2805,11 +2804,11 @@ regular_print: (yyval) = list_append(list_append((yyvsp[0]), (yyvsp[-2])), (yyvsp[-3])); } } -#line 2809 "awkgram.c" /* yacc.c:1646 */ +#line 2808 "awkgram.c" /* yacc.c:1646 */ break; case 64: -#line 1015 "awkgram.y" /* yacc.c:1646 */ +#line 1014 "awkgram.y" /* yacc.c:1646 */ { static bool warned = false; char *arr = (yyvsp[-1])->lextok; @@ -2835,52 +2834,52 @@ regular_print: fatal(_("`delete' is not allowed with FUNCTAB")); } } -#line 2839 "awkgram.c" /* yacc.c:1646 */ +#line 2838 "awkgram.c" /* yacc.c:1646 */ break; case 65: -#line 1041 "awkgram.y" /* yacc.c:1646 */ +#line 1040 "awkgram.y" /* yacc.c:1646 */ { (yyval) = optimize_assignment((yyvsp[0])); } -#line 2845 "awkgram.c" /* yacc.c:1646 */ +#line 2844 "awkgram.c" /* yacc.c:1646 */ break; case 66: -#line 1046 "awkgram.y" /* yacc.c:1646 */ +#line 1045 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2851 "awkgram.c" /* yacc.c:1646 */ +#line 2850 "awkgram.c" /* yacc.c:1646 */ break; case 67: -#line 1048 "awkgram.y" /* yacc.c:1646 */ +#line 1047 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2857 "awkgram.c" /* yacc.c:1646 */ +#line 2856 "awkgram.c" /* yacc.c:1646 */ break; case 68: -#line 1053 "awkgram.y" /* yacc.c:1646 */ +#line 1052 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2863 "awkgram.c" /* yacc.c:1646 */ +#line 2862 "awkgram.c" /* yacc.c:1646 */ break; case 69: -#line 1055 "awkgram.y" /* yacc.c:1646 */ +#line 1054 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-1]) == NULL) (yyval) = list_create((yyvsp[0])); else (yyval) = list_prepend((yyvsp[-1]), (yyvsp[0])); } -#line 2874 "awkgram.c" /* yacc.c:1646 */ +#line 2873 "awkgram.c" /* yacc.c:1646 */ break; case 70: -#line 1062 "awkgram.y" /* yacc.c:1646 */ +#line 1061 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2880 "awkgram.c" /* yacc.c:1646 */ +#line 2879 "awkgram.c" /* yacc.c:1646 */ break; case 71: -#line 1067 "awkgram.y" /* yacc.c:1646 */ +#line 1066 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *casestmt = (yyvsp[0]); if ((yyvsp[0]) == NULL) @@ -2892,11 +2891,11 @@ regular_print: bcfree((yyvsp[-2])); (yyval) = (yyvsp[-4]); } -#line 2896 "awkgram.c" /* yacc.c:1646 */ +#line 2895 "awkgram.c" /* yacc.c:1646 */ break; case 72: -#line 1079 "awkgram.y" /* yacc.c:1646 */ +#line 1078 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *casestmt = (yyvsp[0]); if ((yyvsp[0]) == NULL) @@ -2907,17 +2906,17 @@ regular_print: (yyvsp[-3])->case_stmt = casestmt; (yyval) = (yyvsp[-3]); } -#line 2911 "awkgram.c" /* yacc.c:1646 */ +#line 2910 "awkgram.c" /* yacc.c:1646 */ break; case 73: -#line 1093 "awkgram.y" /* yacc.c:1646 */ +#line 1092 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2917 "awkgram.c" /* yacc.c:1646 */ +#line 2916 "awkgram.c" /* yacc.c:1646 */ break; case 74: -#line 1095 "awkgram.y" /* yacc.c:1646 */ +#line 1094 "awkgram.y" /* yacc.c:1646 */ { NODE *n = (yyvsp[0])->memory; (void) force_number(n); @@ -2925,71 +2924,71 @@ regular_print: bcfree((yyvsp[-1])); (yyval) = (yyvsp[0]); } -#line 2929 "awkgram.c" /* yacc.c:1646 */ +#line 2928 "awkgram.c" /* yacc.c:1646 */ break; case 75: -#line 1103 "awkgram.y" /* yacc.c:1646 */ +#line 1102 "awkgram.y" /* yacc.c:1646 */ { bcfree((yyvsp[-1])); (yyval) = (yyvsp[0]); } -#line 2938 "awkgram.c" /* yacc.c:1646 */ +#line 2937 "awkgram.c" /* yacc.c:1646 */ break; case 76: -#line 1108 "awkgram.y" /* yacc.c:1646 */ +#line 1107 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2944 "awkgram.c" /* yacc.c:1646 */ +#line 2943 "awkgram.c" /* yacc.c:1646 */ break; case 77: -#line 1110 "awkgram.y" /* yacc.c:1646 */ +#line 1109 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_push_re; (yyval) = (yyvsp[0]); } -#line 2953 "awkgram.c" /* yacc.c:1646 */ +#line 2952 "awkgram.c" /* yacc.c:1646 */ break; case 78: -#line 1118 "awkgram.y" /* yacc.c:1646 */ +#line 1117 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2959 "awkgram.c" /* yacc.c:1646 */ +#line 2958 "awkgram.c" /* yacc.c:1646 */ break; case 79: -#line 1120 "awkgram.y" /* yacc.c:1646 */ +#line 1119 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2965 "awkgram.c" /* yacc.c:1646 */ +#line 2964 "awkgram.c" /* yacc.c:1646 */ break; case 81: -#line 1130 "awkgram.y" /* yacc.c:1646 */ +#line 1129 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 2973 "awkgram.c" /* yacc.c:1646 */ +#line 2972 "awkgram.c" /* yacc.c:1646 */ break; case 82: -#line 1137 "awkgram.y" /* yacc.c:1646 */ +#line 1136 "awkgram.y" /* yacc.c:1646 */ { in_print = false; in_parens = 0; (yyval) = NULL; } -#line 2983 "awkgram.c" /* yacc.c:1646 */ +#line 2982 "awkgram.c" /* yacc.c:1646 */ break; case 83: -#line 1142 "awkgram.y" /* yacc.c:1646 */ +#line 1141 "awkgram.y" /* yacc.c:1646 */ { in_print = false; in_parens = 0; } -#line 2989 "awkgram.c" /* yacc.c:1646 */ +#line 2988 "awkgram.c" /* yacc.c:1646 */ break; case 84: -#line 1143 "awkgram.y" /* yacc.c:1646 */ +#line 1142 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-2])->redir_type == redirect_twoway && (yyvsp[0])->lasti->opcode == Op_K_getline_redir @@ -2997,136 +2996,136 @@ regular_print: yyerror(_("multistage two-way pipelines don't work")); (yyval) = list_prepend((yyvsp[0]), (yyvsp[-2])); } -#line 3001 "awkgram.c" /* yacc.c:1646 */ +#line 3000 "awkgram.c" /* yacc.c:1646 */ break; case 85: -#line 1154 "awkgram.y" /* yacc.c:1646 */ +#line 1153 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_condition((yyvsp[-3]), (yyvsp[-5]), (yyvsp[0]), NULL, NULL); } -#line 3009 "awkgram.c" /* yacc.c:1646 */ +#line 3008 "awkgram.c" /* yacc.c:1646 */ break; case 86: -#line 1159 "awkgram.y" /* yacc.c:1646 */ +#line 1158 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_condition((yyvsp[-6]), (yyvsp[-8]), (yyvsp[-3]), (yyvsp[-2]), (yyvsp[0])); } -#line 3017 "awkgram.c" /* yacc.c:1646 */ +#line 3016 "awkgram.c" /* yacc.c:1646 */ break; case 91: -#line 1176 "awkgram.y" /* yacc.c:1646 */ +#line 1175 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3023 "awkgram.c" /* yacc.c:1646 */ +#line 3022 "awkgram.c" /* yacc.c:1646 */ break; case 92: -#line 1178 "awkgram.y" /* yacc.c:1646 */ +#line 1177 "awkgram.y" /* yacc.c:1646 */ { bcfree((yyvsp[-1])); (yyval) = (yyvsp[0]); } -#line 3032 "awkgram.c" /* yacc.c:1646 */ +#line 3031 "awkgram.c" /* yacc.c:1646 */ break; case 93: -#line 1186 "awkgram.y" /* yacc.c:1646 */ +#line 1185 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3038 "awkgram.c" /* yacc.c:1646 */ +#line 3037 "awkgram.c" /* yacc.c:1646 */ break; case 94: -#line 1188 "awkgram.y" /* yacc.c:1646 */ +#line 1187 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]) ; } -#line 3044 "awkgram.c" /* yacc.c:1646 */ +#line 3043 "awkgram.c" /* yacc.c:1646 */ break; case 95: -#line 1193 "awkgram.y" /* yacc.c:1646 */ +#line 1192 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->param_count = 0; (yyval) = list_create((yyvsp[0])); } -#line 3053 "awkgram.c" /* yacc.c:1646 */ +#line 3052 "awkgram.c" /* yacc.c:1646 */ break; case 96: -#line 1198 "awkgram.y" /* yacc.c:1646 */ +#line 1197 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->param_count = (yyvsp[-2])->lasti->param_count + 1; (yyval) = list_append((yyvsp[-2]), (yyvsp[0])); yyerrok; } -#line 3063 "awkgram.c" /* yacc.c:1646 */ +#line 3062 "awkgram.c" /* yacc.c:1646 */ break; case 97: -#line 1204 "awkgram.y" /* yacc.c:1646 */ +#line 1203 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3069 "awkgram.c" /* yacc.c:1646 */ +#line 3068 "awkgram.c" /* yacc.c:1646 */ break; case 98: -#line 1206 "awkgram.y" /* yacc.c:1646 */ +#line 1205 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3075 "awkgram.c" /* yacc.c:1646 */ +#line 3074 "awkgram.c" /* yacc.c:1646 */ break; case 99: -#line 1208 "awkgram.y" /* yacc.c:1646 */ +#line 1207 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-2]); } -#line 3081 "awkgram.c" /* yacc.c:1646 */ +#line 3080 "awkgram.c" /* yacc.c:1646 */ break; case 100: -#line 1214 "awkgram.y" /* yacc.c:1646 */ +#line 1213 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3087 "awkgram.c" /* yacc.c:1646 */ +#line 3086 "awkgram.c" /* yacc.c:1646 */ break; case 101: -#line 1216 "awkgram.y" /* yacc.c:1646 */ +#line 1215 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3093 "awkgram.c" /* yacc.c:1646 */ +#line 3092 "awkgram.c" /* yacc.c:1646 */ break; case 102: -#line 1221 "awkgram.y" /* yacc.c:1646 */ +#line 1220 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3099 "awkgram.c" /* yacc.c:1646 */ +#line 3098 "awkgram.c" /* yacc.c:1646 */ break; case 103: -#line 1223 "awkgram.y" /* yacc.c:1646 */ +#line 1222 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3105 "awkgram.c" /* yacc.c:1646 */ +#line 3104 "awkgram.c" /* yacc.c:1646 */ break; case 104: -#line 1228 "awkgram.y" /* yacc.c:1646 */ +#line 1227 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_expression_list(NULL, (yyvsp[0])); } -#line 3111 "awkgram.c" /* yacc.c:1646 */ +#line 3110 "awkgram.c" /* yacc.c:1646 */ break; case 105: -#line 1230 "awkgram.y" /* yacc.c:1646 */ +#line 1229 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0])); yyerrok; } -#line 3120 "awkgram.c" /* yacc.c:1646 */ +#line 3119 "awkgram.c" /* yacc.c:1646 */ break; case 106: -#line 1235 "awkgram.y" /* yacc.c:1646 */ +#line 1234 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3126 "awkgram.c" /* yacc.c:1646 */ +#line 3125 "awkgram.c" /* yacc.c:1646 */ break; case 107: -#line 1237 "awkgram.y" /* yacc.c:1646 */ +#line 1236 "awkgram.y" /* yacc.c:1646 */ { /* * Returning the expression list instead of NULL lets @@ -3134,52 +3133,52 @@ regular_print: */ (yyval) = (yyvsp[-1]); } -#line 3138 "awkgram.c" /* yacc.c:1646 */ +#line 3137 "awkgram.c" /* yacc.c:1646 */ break; case 108: -#line 1245 "awkgram.y" /* yacc.c:1646 */ +#line 1244 "awkgram.y" /* yacc.c:1646 */ { /* Ditto */ (yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0])); } -#line 3147 "awkgram.c" /* yacc.c:1646 */ +#line 3146 "awkgram.c" /* yacc.c:1646 */ break; case 109: -#line 1250 "awkgram.y" /* yacc.c:1646 */ +#line 1249 "awkgram.y" /* yacc.c:1646 */ { /* Ditto */ (yyval) = (yyvsp[-2]); } -#line 3156 "awkgram.c" /* yacc.c:1646 */ +#line 3155 "awkgram.c" /* yacc.c:1646 */ break; case 110: -#line 1259 "awkgram.y" /* yacc.c:1646 */ +#line 1258 "awkgram.y" /* yacc.c:1646 */ { if (do_lint && (yyvsp[0])->lasti->opcode == Op_match_rec) lintwarn_ln((yyvsp[-1])->source_line, _("regular expression on right of assignment")); (yyval) = mk_assignment((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3167 "awkgram.c" /* yacc.c:1646 */ +#line 3166 "awkgram.c" /* yacc.c:1646 */ break; case 111: -#line 1266 "awkgram.y" /* yacc.c:1646 */ +#line 1265 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3173 "awkgram.c" /* yacc.c:1646 */ +#line 3172 "awkgram.c" /* yacc.c:1646 */ break; case 112: -#line 1268 "awkgram.y" /* yacc.c:1646 */ +#line 1267 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3179 "awkgram.c" /* yacc.c:1646 */ +#line 3178 "awkgram.c" /* yacc.c:1646 */ break; case 113: -#line 1270 "awkgram.y" /* yacc.c:1646 */ +#line 1269 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-2])->lasti->opcode == Op_match_rec) warning_ln((yyvsp[-1])->source_line, @@ -3195,11 +3194,11 @@ regular_print: (yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1])); } } -#line 3199 "awkgram.c" /* yacc.c:1646 */ +#line 3198 "awkgram.c" /* yacc.c:1646 */ break; case 114: -#line 1286 "awkgram.y" /* yacc.c:1646 */ +#line 1285 "awkgram.y" /* yacc.c:1646 */ { if (do_lint_old) warning_ln((yyvsp[-1])->source_line, @@ -3209,91 +3208,91 @@ regular_print: (yyvsp[-1])->expr_count = 1; (yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1])); } -#line 3213 "awkgram.c" /* yacc.c:1646 */ +#line 3212 "awkgram.c" /* yacc.c:1646 */ break; case 115: -#line 1296 "awkgram.y" /* yacc.c:1646 */ +#line 1295 "awkgram.y" /* yacc.c:1646 */ { if (do_lint && (yyvsp[0])->lasti->opcode == Op_match_rec) lintwarn_ln((yyvsp[-1])->source_line, _("regular expression on right of comparison")); (yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1])); } -#line 3224 "awkgram.c" /* yacc.c:1646 */ +#line 3223 "awkgram.c" /* yacc.c:1646 */ break; case 116: -#line 1303 "awkgram.y" /* yacc.c:1646 */ +#line 1302 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_condition((yyvsp[-4]), (yyvsp[-3]), (yyvsp[-2]), (yyvsp[-1]), (yyvsp[0])); } -#line 3230 "awkgram.c" /* yacc.c:1646 */ +#line 3229 "awkgram.c" /* yacc.c:1646 */ break; case 117: -#line 1305 "awkgram.y" /* yacc.c:1646 */ +#line 1304 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3236 "awkgram.c" /* yacc.c:1646 */ +#line 3235 "awkgram.c" /* yacc.c:1646 */ break; case 118: -#line 1310 "awkgram.y" /* yacc.c:1646 */ +#line 1309 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3242 "awkgram.c" /* yacc.c:1646 */ +#line 3241 "awkgram.c" /* yacc.c:1646 */ break; case 119: -#line 1312 "awkgram.y" /* yacc.c:1646 */ +#line 1311 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3248 "awkgram.c" /* yacc.c:1646 */ +#line 3247 "awkgram.c" /* yacc.c:1646 */ break; case 120: -#line 1314 "awkgram.y" /* yacc.c:1646 */ +#line 1313 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_assign_quotient; (yyval) = (yyvsp[0]); } -#line 3257 "awkgram.c" /* yacc.c:1646 */ +#line 3256 "awkgram.c" /* yacc.c:1646 */ break; case 121: -#line 1322 "awkgram.y" /* yacc.c:1646 */ +#line 1321 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3263 "awkgram.c" /* yacc.c:1646 */ +#line 3262 "awkgram.c" /* yacc.c:1646 */ break; case 122: -#line 1324 "awkgram.y" /* yacc.c:1646 */ +#line 1323 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3269 "awkgram.c" /* yacc.c:1646 */ +#line 3268 "awkgram.c" /* yacc.c:1646 */ break; case 123: -#line 1329 "awkgram.y" /* yacc.c:1646 */ +#line 1328 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3275 "awkgram.c" /* yacc.c:1646 */ +#line 3274 "awkgram.c" /* yacc.c:1646 */ break; case 124: -#line 1331 "awkgram.y" /* yacc.c:1646 */ +#line 1330 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3281 "awkgram.c" /* yacc.c:1646 */ +#line 3280 "awkgram.c" /* yacc.c:1646 */ break; case 125: -#line 1336 "awkgram.y" /* yacc.c:1646 */ +#line 1335 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3287 "awkgram.c" /* yacc.c:1646 */ +#line 3286 "awkgram.c" /* yacc.c:1646 */ break; case 126: -#line 1338 "awkgram.y" /* yacc.c:1646 */ +#line 1337 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3293 "awkgram.c" /* yacc.c:1646 */ +#line 3292 "awkgram.c" /* yacc.c:1646 */ break; case 127: -#line 1340 "awkgram.y" /* yacc.c:1646 */ +#line 1339 "awkgram.y" /* yacc.c:1646 */ { int count = 2; bool is_simple_var = false; @@ -3340,47 +3339,47 @@ regular_print: max_args = count; } } -#line 3344 "awkgram.c" /* yacc.c:1646 */ +#line 3343 "awkgram.c" /* yacc.c:1646 */ break; case 129: -#line 1392 "awkgram.y" /* yacc.c:1646 */ +#line 1391 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3350 "awkgram.c" /* yacc.c:1646 */ +#line 3349 "awkgram.c" /* yacc.c:1646 */ break; case 130: -#line 1394 "awkgram.y" /* yacc.c:1646 */ +#line 1393 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3356 "awkgram.c" /* yacc.c:1646 */ +#line 3355 "awkgram.c" /* yacc.c:1646 */ break; case 131: -#line 1396 "awkgram.y" /* yacc.c:1646 */ +#line 1395 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3362 "awkgram.c" /* yacc.c:1646 */ +#line 3361 "awkgram.c" /* yacc.c:1646 */ break; case 132: -#line 1398 "awkgram.y" /* yacc.c:1646 */ +#line 1397 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3368 "awkgram.c" /* yacc.c:1646 */ +#line 3367 "awkgram.c" /* yacc.c:1646 */ break; case 133: -#line 1400 "awkgram.y" /* yacc.c:1646 */ +#line 1399 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3374 "awkgram.c" /* yacc.c:1646 */ +#line 3373 "awkgram.c" /* yacc.c:1646 */ break; case 134: -#line 1402 "awkgram.y" /* yacc.c:1646 */ +#line 1401 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3380 "awkgram.c" /* yacc.c:1646 */ +#line 3379 "awkgram.c" /* yacc.c:1646 */ break; case 135: -#line 1404 "awkgram.y" /* yacc.c:1646 */ +#line 1403 "awkgram.y" /* yacc.c:1646 */ { /* * In BEGINFILE/ENDFILE, allow `getline [var] < file' @@ -3394,29 +3393,29 @@ regular_print: _("non-redirected `getline' undefined inside END action")); (yyval) = mk_getline((yyvsp[-2]), (yyvsp[-1]), (yyvsp[0]), redirect_input); } -#line 3398 "awkgram.c" /* yacc.c:1646 */ +#line 3397 "awkgram.c" /* yacc.c:1646 */ break; case 136: -#line 1418 "awkgram.y" /* yacc.c:1646 */ +#line 1417 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postincrement; (yyval) = mk_assignment((yyvsp[-1]), NULL, (yyvsp[0])); } -#line 3407 "awkgram.c" /* yacc.c:1646 */ +#line 3406 "awkgram.c" /* yacc.c:1646 */ break; case 137: -#line 1423 "awkgram.y" /* yacc.c:1646 */ +#line 1422 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postdecrement; (yyval) = mk_assignment((yyvsp[-1]), NULL, (yyvsp[0])); } -#line 3416 "awkgram.c" /* yacc.c:1646 */ +#line 3415 "awkgram.c" /* yacc.c:1646 */ break; case 138: -#line 1428 "awkgram.y" /* yacc.c:1646 */ +#line 1427 "awkgram.y" /* yacc.c:1646 */ { if (do_lint_old) { warning_ln((yyvsp[-1])->source_line, @@ -3436,64 +3435,64 @@ regular_print: (yyval) = list_append(list_merge(t, (yyvsp[0])), (yyvsp[-1])); } } -#line 3440 "awkgram.c" /* yacc.c:1646 */ +#line 3439 "awkgram.c" /* yacc.c:1646 */ break; case 139: -#line 1453 "awkgram.y" /* yacc.c:1646 */ +#line 1452 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_getline((yyvsp[-1]), (yyvsp[0]), (yyvsp[-3]), (yyvsp[-2])->redir_type); bcfree((yyvsp[-2])); } -#line 3449 "awkgram.c" /* yacc.c:1646 */ +#line 3448 "awkgram.c" /* yacc.c:1646 */ break; case 140: -#line 1459 "awkgram.y" /* yacc.c:1646 */ +#line 1458 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3455 "awkgram.c" /* yacc.c:1646 */ +#line 3454 "awkgram.c" /* yacc.c:1646 */ break; case 141: -#line 1461 "awkgram.y" /* yacc.c:1646 */ +#line 1460 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3461 "awkgram.c" /* yacc.c:1646 */ +#line 3460 "awkgram.c" /* yacc.c:1646 */ break; case 142: -#line 1463 "awkgram.y" /* yacc.c:1646 */ +#line 1462 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3467 "awkgram.c" /* yacc.c:1646 */ +#line 3466 "awkgram.c" /* yacc.c:1646 */ break; case 143: -#line 1465 "awkgram.y" /* yacc.c:1646 */ +#line 1464 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3473 "awkgram.c" /* yacc.c:1646 */ +#line 3472 "awkgram.c" /* yacc.c:1646 */ break; case 144: -#line 1467 "awkgram.y" /* yacc.c:1646 */ +#line 1466 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3479 "awkgram.c" /* yacc.c:1646 */ +#line 3478 "awkgram.c" /* yacc.c:1646 */ break; case 145: -#line 1469 "awkgram.y" /* yacc.c:1646 */ +#line 1468 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3485 "awkgram.c" /* yacc.c:1646 */ +#line 3484 "awkgram.c" /* yacc.c:1646 */ break; case 146: -#line 1474 "awkgram.y" /* yacc.c:1646 */ +#line 1473 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_create((yyvsp[0])); } -#line 3493 "awkgram.c" /* yacc.c:1646 */ +#line 3492 "awkgram.c" /* yacc.c:1646 */ break; case 147: -#line 1478 "awkgram.y" /* yacc.c:1646 */ +#line 1477 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[0])->opcode == Op_match_rec) { (yyvsp[0])->opcode = Op_nomatch; @@ -3525,37 +3524,37 @@ regular_print: } } } -#line 3529 "awkgram.c" /* yacc.c:1646 */ +#line 3528 "awkgram.c" /* yacc.c:1646 */ break; case 148: -#line 1510 "awkgram.y" /* yacc.c:1646 */ +#line 1509 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3535 "awkgram.c" /* yacc.c:1646 */ +#line 3534 "awkgram.c" /* yacc.c:1646 */ break; case 149: -#line 1512 "awkgram.y" /* yacc.c:1646 */ +#line 1511 "awkgram.y" /* yacc.c:1646 */ { (yyval) = snode((yyvsp[-1]), (yyvsp[-3])); if ((yyval) == NULL) YYABORT; } -#line 3545 "awkgram.c" /* yacc.c:1646 */ +#line 3544 "awkgram.c" /* yacc.c:1646 */ break; case 150: -#line 1518 "awkgram.y" /* yacc.c:1646 */ +#line 1517 "awkgram.y" /* yacc.c:1646 */ { (yyval) = snode((yyvsp[-1]), (yyvsp[-3])); if ((yyval) == NULL) YYABORT; } -#line 3555 "awkgram.c" /* yacc.c:1646 */ +#line 3554 "awkgram.c" /* yacc.c:1646 */ break; case 151: -#line 1524 "awkgram.y" /* yacc.c:1646 */ +#line 1523 "awkgram.y" /* yacc.c:1646 */ { static bool warned = false; @@ -3568,45 +3567,45 @@ regular_print: if ((yyval) == NULL) YYABORT; } -#line 3572 "awkgram.c" /* yacc.c:1646 */ +#line 3571 "awkgram.c" /* yacc.c:1646 */ break; case 154: -#line 1539 "awkgram.y" /* yacc.c:1646 */ +#line 1538 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[-1])->opcode = Op_preincrement; (yyval) = mk_assignment((yyvsp[0]), NULL, (yyvsp[-1])); } -#line 3581 "awkgram.c" /* yacc.c:1646 */ +#line 3580 "awkgram.c" /* yacc.c:1646 */ break; case 155: -#line 1544 "awkgram.y" /* yacc.c:1646 */ +#line 1543 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[-1])->opcode = Op_predecrement; (yyval) = mk_assignment((yyvsp[0]), NULL, (yyvsp[-1])); } -#line 3590 "awkgram.c" /* yacc.c:1646 */ +#line 3589 "awkgram.c" /* yacc.c:1646 */ break; case 156: -#line 1549 "awkgram.y" /* yacc.c:1646 */ +#line 1548 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_create((yyvsp[0])); } -#line 3598 "awkgram.c" /* yacc.c:1646 */ +#line 3597 "awkgram.c" /* yacc.c:1646 */ break; case 157: -#line 1553 "awkgram.y" /* yacc.c:1646 */ +#line 1552 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_create((yyvsp[0])); } -#line 3606 "awkgram.c" /* yacc.c:1646 */ +#line 3605 "awkgram.c" /* yacc.c:1646 */ break; case 158: -#line 1557 "awkgram.y" /* yacc.c:1646 */ +#line 1556 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[0])->lasti->opcode == Op_push_i && ((yyvsp[0])->lasti->memory->flags & (STRCUR|STRING)) == 0 @@ -3621,11 +3620,11 @@ regular_print: (yyval) = list_append((yyvsp[0]), (yyvsp[-1])); } } -#line 3625 "awkgram.c" /* yacc.c:1646 */ +#line 3624 "awkgram.c" /* yacc.c:1646 */ break; case 159: -#line 1572 "awkgram.y" /* yacc.c:1646 */ +#line 1571 "awkgram.y" /* yacc.c:1646 */ { /* * was: $$ = $2 @@ -3635,20 +3634,20 @@ regular_print: (yyvsp[-1])->memory = make_number(0.0); (yyval) = list_append((yyvsp[0]), (yyvsp[-1])); } -#line 3639 "awkgram.c" /* yacc.c:1646 */ +#line 3638 "awkgram.c" /* yacc.c:1646 */ break; case 160: -#line 1585 "awkgram.y" /* yacc.c:1646 */ +#line 1584 "awkgram.y" /* yacc.c:1646 */ { func_use((yyvsp[0])->lasti->func_name, FUNC_USE); (yyval) = (yyvsp[0]); } -#line 3648 "awkgram.c" /* yacc.c:1646 */ +#line 3647 "awkgram.c" /* yacc.c:1646 */ break; case 161: -#line 1590 "awkgram.y" /* yacc.c:1646 */ +#line 1589 "awkgram.y" /* yacc.c:1646 */ { /* indirect function call */ INSTRUCTION *f, *t; @@ -3682,11 +3681,11 @@ regular_print: (yyval) = list_prepend((yyvsp[0]), t); at_seen = false; } -#line 3686 "awkgram.c" /* yacc.c:1646 */ +#line 3685 "awkgram.c" /* yacc.c:1646 */ break; case 162: -#line 1627 "awkgram.y" /* yacc.c:1646 */ +#line 1626 "awkgram.y" /* yacc.c:1646 */ { NODE *n; @@ -3711,49 +3710,49 @@ regular_print: (yyval) = list_append(t, (yyvsp[-3])); } } -#line 3715 "awkgram.c" /* yacc.c:1646 */ +#line 3714 "awkgram.c" /* yacc.c:1646 */ break; case 163: -#line 1655 "awkgram.y" /* yacc.c:1646 */ +#line 1654 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3721 "awkgram.c" /* yacc.c:1646 */ +#line 3720 "awkgram.c" /* yacc.c:1646 */ break; case 164: -#line 1657 "awkgram.y" /* yacc.c:1646 */ +#line 1656 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3727 "awkgram.c" /* yacc.c:1646 */ +#line 3726 "awkgram.c" /* yacc.c:1646 */ break; case 165: -#line 1662 "awkgram.y" /* yacc.c:1646 */ +#line 1661 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3733 "awkgram.c" /* yacc.c:1646 */ +#line 3732 "awkgram.c" /* yacc.c:1646 */ break; case 166: -#line 1664 "awkgram.y" /* yacc.c:1646 */ +#line 1663 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3739 "awkgram.c" /* yacc.c:1646 */ +#line 3738 "awkgram.c" /* yacc.c:1646 */ break; case 167: -#line 1669 "awkgram.y" /* yacc.c:1646 */ +#line 1668 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3745 "awkgram.c" /* yacc.c:1646 */ +#line 3744 "awkgram.c" /* yacc.c:1646 */ break; case 168: -#line 1671 "awkgram.y" /* yacc.c:1646 */ +#line 1670 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_merge((yyvsp[-1]), (yyvsp[0])); } -#line 3753 "awkgram.c" /* yacc.c:1646 */ +#line 3752 "awkgram.c" /* yacc.c:1646 */ break; case 169: -#line 1678 "awkgram.y" /* yacc.c:1646 */ +#line 1677 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *ip = (yyvsp[0])->lasti; int count = ip->sub_count; /* # of SUBSEP-seperated expressions */ @@ -3767,11 +3766,11 @@ regular_print: sub_counter++; /* count # of dimensions */ (yyval) = (yyvsp[0]); } -#line 3771 "awkgram.c" /* yacc.c:1646 */ +#line 3770 "awkgram.c" /* yacc.c:1646 */ break; case 170: -#line 1695 "awkgram.y" /* yacc.c:1646 */ +#line 1694 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *t = (yyvsp[-1]); if ((yyvsp[-1]) == NULL) { @@ -3785,31 +3784,31 @@ regular_print: (yyvsp[0])->sub_count = count_expressions(&t, false); (yyval) = list_append(t, (yyvsp[0])); } -#line 3789 "awkgram.c" /* yacc.c:1646 */ +#line 3788 "awkgram.c" /* yacc.c:1646 */ break; case 171: -#line 1712 "awkgram.y" /* yacc.c:1646 */ +#line 1711 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3795 "awkgram.c" /* yacc.c:1646 */ +#line 3794 "awkgram.c" /* yacc.c:1646 */ break; case 172: -#line 1714 "awkgram.y" /* yacc.c:1646 */ +#line 1713 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_merge((yyvsp[-1]), (yyvsp[0])); } -#line 3803 "awkgram.c" /* yacc.c:1646 */ +#line 3802 "awkgram.c" /* yacc.c:1646 */ break; case 173: -#line 1721 "awkgram.y" /* yacc.c:1646 */ +#line 1720 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3809 "awkgram.c" /* yacc.c:1646 */ +#line 3808 "awkgram.c" /* yacc.c:1646 */ break; case 174: -#line 1726 "awkgram.y" /* yacc.c:1646 */ +#line 1725 "awkgram.y" /* yacc.c:1646 */ { char *var_name = (yyvsp[0])->lextok; @@ -3817,22 +3816,22 @@ regular_print: (yyvsp[0])->memory = variable((yyvsp[0])->source_line, var_name, Node_var_new); (yyval) = list_create((yyvsp[0])); } -#line 3821 "awkgram.c" /* yacc.c:1646 */ +#line 3820 "awkgram.c" /* yacc.c:1646 */ break; case 175: -#line 1734 "awkgram.y" /* yacc.c:1646 */ +#line 1733 "awkgram.y" /* yacc.c:1646 */ { char *arr = (yyvsp[-1])->lextok; (yyvsp[-1])->memory = variable((yyvsp[-1])->source_line, arr, Node_var_new); (yyvsp[-1])->opcode = Op_push_array; (yyval) = list_prepend((yyvsp[0]), (yyvsp[-1])); } -#line 3832 "awkgram.c" /* yacc.c:1646 */ +#line 3831 "awkgram.c" /* yacc.c:1646 */ break; case 176: -#line 1744 "awkgram.y" /* yacc.c:1646 */ +#line 1743 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *ip = (yyvsp[0])->nexti; if (ip->opcode == Op_push @@ -3844,73 +3843,73 @@ regular_print: } else (yyval) = (yyvsp[0]); } -#line 3848 "awkgram.c" /* yacc.c:1646 */ +#line 3847 "awkgram.c" /* yacc.c:1646 */ break; case 177: -#line 1756 "awkgram.y" /* yacc.c:1646 */ +#line 1755 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_append((yyvsp[-1]), (yyvsp[-2])); if ((yyvsp[0]) != NULL) mk_assignment((yyvsp[-1]), NULL, (yyvsp[0])); } -#line 3858 "awkgram.c" /* yacc.c:1646 */ +#line 3857 "awkgram.c" /* yacc.c:1646 */ break; case 178: -#line 1765 "awkgram.y" /* yacc.c:1646 */ +#line 1764 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postincrement; } -#line 3866 "awkgram.c" /* yacc.c:1646 */ +#line 3865 "awkgram.c" /* yacc.c:1646 */ break; case 179: -#line 1769 "awkgram.y" /* yacc.c:1646 */ +#line 1768 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postdecrement; } -#line 3874 "awkgram.c" /* yacc.c:1646 */ +#line 3873 "awkgram.c" /* yacc.c:1646 */ break; case 180: -#line 1772 "awkgram.y" /* yacc.c:1646 */ +#line 1771 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3880 "awkgram.c" /* yacc.c:1646 */ +#line 3879 "awkgram.c" /* yacc.c:1646 */ break; case 182: -#line 1780 "awkgram.y" /* yacc.c:1646 */ +#line 1779 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3886 "awkgram.c" /* yacc.c:1646 */ +#line 3885 "awkgram.c" /* yacc.c:1646 */ break; case 183: -#line 1784 "awkgram.y" /* yacc.c:1646 */ +#line 1783 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3892 "awkgram.c" /* yacc.c:1646 */ +#line 3891 "awkgram.c" /* yacc.c:1646 */ break; case 186: -#line 1793 "awkgram.y" /* yacc.c:1646 */ +#line 1792 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3898 "awkgram.c" /* yacc.c:1646 */ +#line 3897 "awkgram.c" /* yacc.c:1646 */ break; case 187: -#line 1797 "awkgram.y" /* yacc.c:1646 */ +#line 1796 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); yyerrok; } -#line 3904 "awkgram.c" /* yacc.c:1646 */ +#line 3903 "awkgram.c" /* yacc.c:1646 */ break; case 188: -#line 1801 "awkgram.y" /* yacc.c:1646 */ +#line 1800 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3910 "awkgram.c" /* yacc.c:1646 */ +#line 3909 "awkgram.c" /* yacc.c:1646 */ break; -#line 3914 "awkgram.c" /* yacc.c:1646 */ +#line 3913 "awkgram.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -4138,7 +4137,7 @@ yyreturn: #endif return yyresult; } -#line 1803 "awkgram.y" /* yacc.c:1906 */ +#line 1802 "awkgram.y" /* yacc.c:1906 */ struct token { @@ -6816,7 +6815,7 @@ variable(int location, char *name, NODETYPE type) /* make_regnode --- make a regular expression node */ -static NODE * +NODE * make_regnode(int type, NODE *exp) { NODE *n; @@ -7969,13 +7968,26 @@ lookup_builtin(const char *name) { int mid = check_special(name); - if (mid == -1 || tokentab[mid].class != LEX_BUILTIN) + if (mid == -1) return NULL; + + switch (tokentab[mid].class) { + case LEX_BUILTIN: + case LEX_LENGTH: + break; + default: + return NULL; + } + #ifdef HAVE_MPFR if (do_mpfr) return tokentab[mid].ptr2; #endif + /* And another special case... */ + if (tokentab[mid].value == Op_sub_builtin) + return (builtin_func_t) do_sub; + return tokentab[mid].ptr; } @@ -7988,7 +8000,8 @@ install_builtins(void) j = sizeof(tokentab) / sizeof(tokentab[0]); for (i = 0; i < j; i++) { - if ( tokentab[i].class == LEX_BUILTIN + if ( (tokentab[i].class == LEX_BUILTIN + || tokentab[i].class == LEX_LENGTH) && (tokentab[i].flags & DEBUG_USE) == 0) { (void) install_symbol(tokentab[i].operator, Node_builtin_func); } @@ -73,7 +73,6 @@ static INSTRUCTION *mk_binary(INSTRUCTION *s1, INSTRUCTION *s2, INSTRUCTION *op) static INSTRUCTION *mk_boolean(INSTRUCTION *left, INSTRUCTION *right, INSTRUCTION *op); static INSTRUCTION *mk_assignment(INSTRUCTION *lhs, INSTRUCTION *rhs, INSTRUCTION *op); static INSTRUCTION *mk_getline(INSTRUCTION *op, INSTRUCTION *opt_var, INSTRUCTION *redir, int redirtype); -static NODE *make_regnode(int type, NODE *exp); static int count_expressions(INSTRUCTION **list, bool isarg); static INSTRUCTION *optimize_assignment(INSTRUCTION *exp); static void add_lint(INSTRUCTION *list, LINTTYPE linttype); @@ -4477,7 +4476,7 @@ variable(int location, char *name, NODETYPE type) /* make_regnode --- make a regular expression node */ -static NODE * +NODE * make_regnode(int type, NODE *exp) { NODE *n; @@ -5630,13 +5629,26 @@ lookup_builtin(const char *name) { int mid = check_special(name); - if (mid == -1 || tokentab[mid].class != LEX_BUILTIN) + if (mid == -1) return NULL; + + switch (tokentab[mid].class) { + case LEX_BUILTIN: + case LEX_LENGTH: + break; + default: + return NULL; + } + #ifdef HAVE_MPFR if (do_mpfr) return tokentab[mid].ptr2; #endif + /* And another special case... */ + if (tokentab[mid].value == Op_sub_builtin) + return (builtin_func_t) do_sub; + return tokentab[mid].ptr; } @@ -5649,7 +5661,8 @@ install_builtins(void) j = sizeof(tokentab) / sizeof(tokentab[0]); for (i = 0; i < j; i++) { - if ( tokentab[i].class == LEX_BUILTIN + if ( (tokentab[i].class == LEX_BUILTIN + || tokentab[i].class == LEX_LENGTH) && (tokentab[i].flags & DEBUG_USE) == 0) { (void) install_symbol(tokentab[i].operator, Node_builtin_func); } @@ -2994,6 +2994,146 @@ done: return make_number((AWKNUM) matches); } +/* call_sub --- call do_sub indirectly */ + +NODE * +call_sub(const char *name, int nargs) +{ + unsigned int flags = 0; + NODE *regex, *replace, *glob_flag; + NODE **lhs, *rhs; + NODE *zero = make_number(0.0); + NODE *result; + + if (name[0] == 'g') { + if (name[1] == 'e') + flags = GENSUB; + else + flags = GSUB; + } + + if (flags == 0 || flags == GSUB) { + /* sub or gsub */ + if (nargs != 2) + fatal(_("%s: can be called indirectly only with two arguments"), name); + + replace = POP_STRING(); + regex = POP(); /* the regex */ + /* + * push regex + * push replace + * push $0 + */ + regex = make_regnode(Node_regex, regex); + PUSH(regex); + PUSH(replace); + lhs = r_get_field(zero, (Func_ptr *) 0, true); + nargs++; + PUSH_ADDRESS(lhs); + } else { + /* gensub */ + if (nargs == 4) + rhs = POP(); + else + rhs = NULL; + glob_flag = POP_STRING(); + replace = POP_STRING(); + regex = POP(); /* the regex */ + /* + * push regex + * push replace + * push glob_flag + * if (nargs = 3) { + * push $0 + * nargs++ + * } + */ + regex = make_regnode(Node_regex, regex); + PUSH(regex); + PUSH(replace); + PUSH(glob_flag); + if (rhs == NULL) { + lhs = r_get_field(zero, (Func_ptr *) 0, true); + rhs = *lhs; + UPREF(rhs); + PUSH(rhs); + nargs++; + } + PUSH(rhs); + } + + + unref(zero); + result = do_sub(nargs, flags); + if (flags != GENSUB) + reset_record(); + return result; +} + +/* call_match --- call do_match indirectly */ + +NODE * +call_match(int nargs) +{ + NODE *regex, *text, *array; + NODE *result; + + regex = text = array = NULL; + if (nargs == 3) + array = POP(); + regex = POP(); + + /* Don't need to pop the string just to push it back ... */ + + regex = make_regnode(Node_regex, regex); + PUSH(regex); + + if (array) + PUSH(array); + + result = do_match(nargs); + return result; +} + +/* call_split_func --- call do_split or do_pat_split indirectly */ + +NODE * +call_split_func(const char *name, int nargs) +{ + NODE *regex, *seps; + NODE *result; + + regex = seps = NULL; + if (nargs < 2) + fatal(_("indirect call to %s requires at least two arguments"), + name); + + if (nargs == 4) + seps = POP(); + + if (nargs >= 3) { + regex = POP_STRING(); + regex = make_regnode(Node_regex, regex); + } else { + if (name[0] == 's') { + regex = make_regnode(Node_regex, FS_node->var_value); + regex->re_flags |= FS_DFLT; + } else + regex = make_regnode(Node_regex, FPAT_node->var_value); + nargs++; + } + + /* Don't need to pop the string or the data array */ + + PUSH(regex); + + if (seps) + PUSH(seps); + + result = (name[0] == 's') ? do_split(nargs) : do_patsplit(nargs); + + return result; +} /* make_integer - Convert an integer to a number node. */ diff --git a/doc/ChangeLog b/doc/ChangeLog index 6dbe79dc..2f5dabb0 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2015-03-31 Arnold D. Robbins <arnold@skeeve.com> + + * gawktexi.in: Update discussion of calling built-in functions + indirectly. + 2015-03-24 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in: Minor fixes from Antonio Colombo and new exercise diff --git a/doc/gawk.info b/doc/gawk.info index 6cb2abdb..9b6a46fc 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -14294,9 +14294,17 @@ function call. Starting with version 4.1.2 of `gawk', indirect function calls may also be used with built-in functions and with extension functions -(*note Dynamic Extensions::). The only thing you cannot do is pass a -regular expression constant to a built-in function through an indirect -function call.(1) +(*note Dynamic Extensions::). There are some limitations when calling +built-in functions indirectly, as follows. + + * You cannot pass a regular expression constant to a built-in + function through an indirect function call.(1) This applies to the + `sub()', `gsub()', `gensub()', `match()', `split()' and + `patsplit()' functions. + + * If calling `sub()' or `gsub()', you may only pass two arguments, + since those functions are unusual in that they update their third + argument. This means that `$0' will be updated. `gawk' does its best to make indirect function calls efficient. For example, in the following case: @@ -34777,292 +34785,292 @@ Node: Pass By Value/Reference579678 Node: Return Statement583175 Node: Dynamic Typing586154 Node: Indirect Calls587083 -Ref: Indirect Calls-Footnote-1596948 -Node: Functions Summary597076 -Node: Library Functions599778 -Ref: Library Functions-Footnote-1603386 -Ref: Library Functions-Footnote-2603529 -Node: Library Names603700 -Ref: Library Names-Footnote-1607158 -Ref: Library Names-Footnote-2607381 -Node: General Functions607467 -Node: Strtonum Function608570 -Node: Assert Function611592 -Node: Round Function614916 -Node: Cliff Random Function616457 -Node: Ordinal Functions617473 -Ref: Ordinal Functions-Footnote-1620536 -Ref: Ordinal Functions-Footnote-2620788 -Node: Join Function620999 -Ref: Join Function-Footnote-1622769 -Node: Getlocaltime Function622969 -Node: Readfile Function626713 -Node: Shell Quoting628685 -Node: Data File Management630086 -Node: Filetrans Function630718 -Node: Rewind Function634814 -Node: File Checking636200 -Ref: File Checking-Footnote-1637533 -Node: Empty Files637734 -Node: Ignoring Assigns639713 -Node: Getopt Function641263 -Ref: Getopt Function-Footnote-1652727 -Node: Passwd Functions652927 -Ref: Passwd Functions-Footnote-1661767 -Node: Group Functions661855 -Ref: Group Functions-Footnote-1669752 -Node: Walking Arrays669957 -Node: Library Functions Summary672963 -Node: Library Exercises674365 -Node: Sample Programs675645 -Node: Running Examples676415 -Node: Clones677143 -Node: Cut Program678367 -Node: Egrep Program688087 -Ref: Egrep Program-Footnote-1695590 -Node: Id Program695700 -Node: Split Program699376 -Ref: Split Program-Footnote-1702830 -Node: Tee Program702958 -Node: Uniq Program705747 -Node: Wc Program713166 -Ref: Wc Program-Footnote-1717416 -Node: Miscellaneous Programs717510 -Node: Dupword Program718723 -Node: Alarm Program720754 -Node: Translate Program725559 -Ref: Translate Program-Footnote-1730122 -Node: Labels Program730392 -Ref: Labels Program-Footnote-1733743 -Node: Word Sorting733827 -Node: History Sorting737897 -Node: Extract Program739732 -Node: Simple Sed747256 -Node: Igawk Program750326 -Ref: Igawk Program-Footnote-1764652 -Ref: Igawk Program-Footnote-2764853 -Ref: Igawk Program-Footnote-3764975 -Node: Anagram Program765090 -Node: Signature Program768151 -Node: Programs Summary769398 -Node: Programs Exercises770619 -Ref: Programs Exercises-Footnote-1774750 -Node: Advanced Features774841 -Node: Nondecimal Data776823 -Node: Array Sorting778413 -Node: Controlling Array Traversal779113 -Ref: Controlling Array Traversal-Footnote-1787479 -Node: Array Sorting Functions787597 -Ref: Array Sorting Functions-Footnote-1791483 -Node: Two-way I/O791679 -Ref: Two-way I/O-Footnote-1796624 -Ref: Two-way I/O-Footnote-2796810 -Node: TCP/IP Networking796892 -Node: Profiling799764 -Node: Advanced Features Summary807305 -Node: Internationalization809238 -Node: I18N and L10N810718 -Node: Explaining gettext811404 -Ref: Explaining gettext-Footnote-1816429 -Ref: Explaining gettext-Footnote-2816613 -Node: Programmer i18n816778 -Ref: Programmer i18n-Footnote-1821654 -Node: Translator i18n821703 -Node: String Extraction822497 -Ref: String Extraction-Footnote-1823628 -Node: Printf Ordering823714 -Ref: Printf Ordering-Footnote-1826500 -Node: I18N Portability826564 -Ref: I18N Portability-Footnote-1829020 -Node: I18N Example829083 -Ref: I18N Example-Footnote-1831886 -Node: Gawk I18N831958 -Node: I18N Summary832602 -Node: Debugger833942 -Node: Debugging834964 -Node: Debugging Concepts835405 -Node: Debugging Terms837215 -Node: Awk Debugging839787 -Node: Sample Debugging Session840693 -Node: Debugger Invocation841227 -Node: Finding The Bug842612 -Node: List of Debugger Commands849091 -Node: Breakpoint Control850423 -Node: Debugger Execution Control854100 -Node: Viewing And Changing Data857459 -Node: Execution Stack860835 -Node: Debugger Info862470 -Node: Miscellaneous Debugger Commands866515 -Node: Readline Support871516 -Node: Limitations872410 -Node: Debugging Summary874525 -Node: Arbitrary Precision Arithmetic875699 -Node: Computer Arithmetic877115 -Ref: table-numeric-ranges880692 -Ref: Computer Arithmetic-Footnote-1881216 -Node: Math Definitions881273 -Ref: table-ieee-formats884568 -Ref: Math Definitions-Footnote-1885172 -Node: MPFR features885277 -Node: FP Math Caution886948 -Ref: FP Math Caution-Footnote-1887998 -Node: Inexactness of computations888367 -Node: Inexact representation889326 -Node: Comparing FP Values890684 -Node: Errors accumulate891766 -Node: Getting Accuracy893198 -Node: Try To Round895902 -Node: Setting precision896801 -Ref: table-predefined-precision-strings897485 -Node: Setting the rounding mode899314 -Ref: table-gawk-rounding-modes899678 -Ref: Setting the rounding mode-Footnote-1903130 -Node: Arbitrary Precision Integers903309 -Ref: Arbitrary Precision Integers-Footnote-1906293 -Node: POSIX Floating Point Problems906442 -Ref: POSIX Floating Point Problems-Footnote-1910321 -Node: Floating point summary910359 -Node: Dynamic Extensions912546 -Node: Extension Intro914098 -Node: Plugin License915363 -Node: Extension Mechanism Outline916160 -Ref: figure-load-extension916588 -Ref: figure-register-new-function918068 -Ref: figure-call-new-function919072 -Node: Extension API Description921059 -Node: Extension API Functions Introduction922509 -Node: General Data Types927330 -Ref: General Data Types-Footnote-1933230 -Node: Memory Allocation Functions933529 -Ref: Memory Allocation Functions-Footnote-1936368 -Node: Constructor Functions936467 -Node: Registration Functions938206 -Node: Extension Functions938891 -Node: Exit Callback Functions941188 -Node: Extension Version String942436 -Node: Input Parsers943099 -Node: Output Wrappers952974 -Node: Two-way processors957487 -Node: Printing Messages959750 -Ref: Printing Messages-Footnote-1960826 -Node: Updating `ERRNO'960978 -Node: Requesting Values961718 -Ref: table-value-types-returned962445 -Node: Accessing Parameters963402 -Node: Symbol Table Access964636 -Node: Symbol table by name965150 -Node: Symbol table by cookie967170 -Ref: Symbol table by cookie-Footnote-1971315 -Node: Cached values971378 -Ref: Cached values-Footnote-1974874 -Node: Array Manipulation974965 -Ref: Array Manipulation-Footnote-1976063 -Node: Array Data Types976100 -Ref: Array Data Types-Footnote-1978755 -Node: Array Functions978847 -Node: Flattening Arrays982706 -Node: Creating Arrays989608 -Node: Extension API Variables994379 -Node: Extension Versioning995015 -Node: Extension API Informational Variables996906 -Node: Extension API Boilerplate997971 -Node: Finding Extensions1001780 -Node: Extension Example1002340 -Node: Internal File Description1003112 -Node: Internal File Ops1007179 -Ref: Internal File Ops-Footnote-11018930 -Node: Using Internal File Ops1019070 -Ref: Using Internal File Ops-Footnote-11021453 -Node: Extension Samples1021726 -Node: Extension Sample File Functions1023254 -Node: Extension Sample Fnmatch1030935 -Node: Extension Sample Fork1032423 -Node: Extension Sample Inplace1033638 -Node: Extension Sample Ord1035724 -Node: Extension Sample Readdir1036560 -Ref: table-readdir-file-types1037437 -Node: Extension Sample Revout1038248 -Node: Extension Sample Rev2way1038837 -Node: Extension Sample Read write array1039577 -Node: Extension Sample Readfile1041517 -Node: Extension Sample Time1042612 -Node: Extension Sample API Tests1043960 -Node: gawkextlib1044451 -Node: Extension summary1047129 -Node: Extension Exercises1050818 -Node: Language History1052314 -Node: V7/SVR3.11053970 -Node: SVR41056123 -Node: POSIX1057557 -Node: BTL1058938 -Node: POSIX/GNU1059669 -Node: Feature History1065190 -Node: Common Extensions1078288 -Node: Ranges and Locales1079660 -Ref: Ranges and Locales-Footnote-11084279 -Ref: Ranges and Locales-Footnote-21084306 -Ref: Ranges and Locales-Footnote-31084541 -Node: Contributors1084762 -Node: History summary1090302 -Node: Installation1091681 -Node: Gawk Distribution1092627 -Node: Getting1093111 -Node: Extracting1093934 -Node: Distribution contents1095571 -Node: Unix Installation1101325 -Node: Quick Installation1101942 -Node: Additional Configuration Options1104366 -Node: Configuration Philosophy1106169 -Node: Non-Unix Installation1108538 -Node: PC Installation1108996 -Node: PC Binary Installation1110316 -Node: PC Compiling1112164 -Ref: PC Compiling-Footnote-11115185 -Node: PC Testing1115294 -Node: PC Using1116470 -Node: Cygwin1120585 -Node: MSYS1121355 -Node: VMS Installation1121856 -Node: VMS Compilation1122648 -Ref: VMS Compilation-Footnote-11123877 -Node: VMS Dynamic Extensions1123935 -Node: VMS Installation Details1125619 -Node: VMS Running1127870 -Node: VMS GNV1130710 -Node: VMS Old Gawk1131445 -Node: Bugs1131915 -Node: Other Versions1135804 -Node: Installation summary1142238 -Node: Notes1143297 -Node: Compatibility Mode1144162 -Node: Additions1144944 -Node: Accessing The Source1145869 -Node: Adding Code1147304 -Node: New Ports1153461 -Node: Derived Files1157943 -Ref: Derived Files-Footnote-11163418 -Ref: Derived Files-Footnote-21163452 -Ref: Derived Files-Footnote-31164048 -Node: Future Extensions1164162 -Node: Implementation Limitations1164768 -Node: Extension Design1166016 -Node: Old Extension Problems1167170 -Ref: Old Extension Problems-Footnote-11168687 -Node: Extension New Mechanism Goals1168744 -Ref: Extension New Mechanism Goals-Footnote-11172104 -Node: Extension Other Design Decisions1172293 -Node: Extension Future Growth1174401 -Node: Old Extension Mechanism1175237 -Node: Notes summary1176999 -Node: Basic Concepts1178185 -Node: Basic High Level1178866 -Ref: figure-general-flow1179138 -Ref: figure-process-flow1179737 -Ref: Basic High Level-Footnote-11182966 -Node: Basic Data Typing1183151 -Node: Glossary1186479 -Node: Copying1218408 -Node: GNU Free Documentation License1255964 -Node: Index1281100 +Ref: Indirect Calls-Footnote-1597326 +Node: Functions Summary597454 +Node: Library Functions600156 +Ref: Library Functions-Footnote-1603764 +Ref: Library Functions-Footnote-2603907 +Node: Library Names604078 +Ref: Library Names-Footnote-1607536 +Ref: Library Names-Footnote-2607759 +Node: General Functions607845 +Node: Strtonum Function608948 +Node: Assert Function611970 +Node: Round Function615294 +Node: Cliff Random Function616835 +Node: Ordinal Functions617851 +Ref: Ordinal Functions-Footnote-1620914 +Ref: Ordinal Functions-Footnote-2621166 +Node: Join Function621377 +Ref: Join Function-Footnote-1623147 +Node: Getlocaltime Function623347 +Node: Readfile Function627091 +Node: Shell Quoting629063 +Node: Data File Management630464 +Node: Filetrans Function631096 +Node: Rewind Function635192 +Node: File Checking636578 +Ref: File Checking-Footnote-1637911 +Node: Empty Files638112 +Node: Ignoring Assigns640091 +Node: Getopt Function641641 +Ref: Getopt Function-Footnote-1653105 +Node: Passwd Functions653305 +Ref: Passwd Functions-Footnote-1662145 +Node: Group Functions662233 +Ref: Group Functions-Footnote-1670130 +Node: Walking Arrays670335 +Node: Library Functions Summary673341 +Node: Library Exercises674743 +Node: Sample Programs676023 +Node: Running Examples676793 +Node: Clones677521 +Node: Cut Program678745 +Node: Egrep Program688465 +Ref: Egrep Program-Footnote-1695968 +Node: Id Program696078 +Node: Split Program699754 +Ref: Split Program-Footnote-1703208 +Node: Tee Program703336 +Node: Uniq Program706125 +Node: Wc Program713544 +Ref: Wc Program-Footnote-1717794 +Node: Miscellaneous Programs717888 +Node: Dupword Program719101 +Node: Alarm Program721132 +Node: Translate Program725937 +Ref: Translate Program-Footnote-1730500 +Node: Labels Program730770 +Ref: Labels Program-Footnote-1734121 +Node: Word Sorting734205 +Node: History Sorting738275 +Node: Extract Program740110 +Node: Simple Sed747634 +Node: Igawk Program750704 +Ref: Igawk Program-Footnote-1765030 +Ref: Igawk Program-Footnote-2765231 +Ref: Igawk Program-Footnote-3765353 +Node: Anagram Program765468 +Node: Signature Program768529 +Node: Programs Summary769776 +Node: Programs Exercises770997 +Ref: Programs Exercises-Footnote-1775128 +Node: Advanced Features775219 +Node: Nondecimal Data777201 +Node: Array Sorting778791 +Node: Controlling Array Traversal779491 +Ref: Controlling Array Traversal-Footnote-1787857 +Node: Array Sorting Functions787975 +Ref: Array Sorting Functions-Footnote-1791861 +Node: Two-way I/O792057 +Ref: Two-way I/O-Footnote-1797002 +Ref: Two-way I/O-Footnote-2797188 +Node: TCP/IP Networking797270 +Node: Profiling800142 +Node: Advanced Features Summary807683 +Node: Internationalization809616 +Node: I18N and L10N811096 +Node: Explaining gettext811782 +Ref: Explaining gettext-Footnote-1816807 +Ref: Explaining gettext-Footnote-2816991 +Node: Programmer i18n817156 +Ref: Programmer i18n-Footnote-1822032 +Node: Translator i18n822081 +Node: String Extraction822875 +Ref: String Extraction-Footnote-1824006 +Node: Printf Ordering824092 +Ref: Printf Ordering-Footnote-1826878 +Node: I18N Portability826942 +Ref: I18N Portability-Footnote-1829398 +Node: I18N Example829461 +Ref: I18N Example-Footnote-1832264 +Node: Gawk I18N832336 +Node: I18N Summary832980 +Node: Debugger834320 +Node: Debugging835342 +Node: Debugging Concepts835783 +Node: Debugging Terms837593 +Node: Awk Debugging840165 +Node: Sample Debugging Session841071 +Node: Debugger Invocation841605 +Node: Finding The Bug842990 +Node: List of Debugger Commands849469 +Node: Breakpoint Control850801 +Node: Debugger Execution Control854478 +Node: Viewing And Changing Data857837 +Node: Execution Stack861213 +Node: Debugger Info862848 +Node: Miscellaneous Debugger Commands866893 +Node: Readline Support871894 +Node: Limitations872788 +Node: Debugging Summary874903 +Node: Arbitrary Precision Arithmetic876077 +Node: Computer Arithmetic877493 +Ref: table-numeric-ranges881070 +Ref: Computer Arithmetic-Footnote-1881594 +Node: Math Definitions881651 +Ref: table-ieee-formats884946 +Ref: Math Definitions-Footnote-1885550 +Node: MPFR features885655 +Node: FP Math Caution887326 +Ref: FP Math Caution-Footnote-1888376 +Node: Inexactness of computations888745 +Node: Inexact representation889704 +Node: Comparing FP Values891062 +Node: Errors accumulate892144 +Node: Getting Accuracy893576 +Node: Try To Round896280 +Node: Setting precision897179 +Ref: table-predefined-precision-strings897863 +Node: Setting the rounding mode899692 +Ref: table-gawk-rounding-modes900056 +Ref: Setting the rounding mode-Footnote-1903508 +Node: Arbitrary Precision Integers903687 +Ref: Arbitrary Precision Integers-Footnote-1906671 +Node: POSIX Floating Point Problems906820 +Ref: POSIX Floating Point Problems-Footnote-1910699 +Node: Floating point summary910737 +Node: Dynamic Extensions912924 +Node: Extension Intro914476 +Node: Plugin License915741 +Node: Extension Mechanism Outline916538 +Ref: figure-load-extension916966 +Ref: figure-register-new-function918446 +Ref: figure-call-new-function919450 +Node: Extension API Description921437 +Node: Extension API Functions Introduction922887 +Node: General Data Types927708 +Ref: General Data Types-Footnote-1933608 +Node: Memory Allocation Functions933907 +Ref: Memory Allocation Functions-Footnote-1936746 +Node: Constructor Functions936845 +Node: Registration Functions938584 +Node: Extension Functions939269 +Node: Exit Callback Functions941566 +Node: Extension Version String942814 +Node: Input Parsers943477 +Node: Output Wrappers953352 +Node: Two-way processors957865 +Node: Printing Messages960128 +Ref: Printing Messages-Footnote-1961204 +Node: Updating `ERRNO'961356 +Node: Requesting Values962096 +Ref: table-value-types-returned962823 +Node: Accessing Parameters963780 +Node: Symbol Table Access965014 +Node: Symbol table by name965528 +Node: Symbol table by cookie967548 +Ref: Symbol table by cookie-Footnote-1971693 +Node: Cached values971756 +Ref: Cached values-Footnote-1975252 +Node: Array Manipulation975343 +Ref: Array Manipulation-Footnote-1976441 +Node: Array Data Types976478 +Ref: Array Data Types-Footnote-1979133 +Node: Array Functions979225 +Node: Flattening Arrays983084 +Node: Creating Arrays989986 +Node: Extension API Variables994757 +Node: Extension Versioning995393 +Node: Extension API Informational Variables997284 +Node: Extension API Boilerplate998349 +Node: Finding Extensions1002158 +Node: Extension Example1002718 +Node: Internal File Description1003490 +Node: Internal File Ops1007557 +Ref: Internal File Ops-Footnote-11019308 +Node: Using Internal File Ops1019448 +Ref: Using Internal File Ops-Footnote-11021831 +Node: Extension Samples1022104 +Node: Extension Sample File Functions1023632 +Node: Extension Sample Fnmatch1031313 +Node: Extension Sample Fork1032801 +Node: Extension Sample Inplace1034016 +Node: Extension Sample Ord1036102 +Node: Extension Sample Readdir1036938 +Ref: table-readdir-file-types1037815 +Node: Extension Sample Revout1038626 +Node: Extension Sample Rev2way1039215 +Node: Extension Sample Read write array1039955 +Node: Extension Sample Readfile1041895 +Node: Extension Sample Time1042990 +Node: Extension Sample API Tests1044338 +Node: gawkextlib1044829 +Node: Extension summary1047507 +Node: Extension Exercises1051196 +Node: Language History1052692 +Node: V7/SVR3.11054348 +Node: SVR41056501 +Node: POSIX1057935 +Node: BTL1059316 +Node: POSIX/GNU1060047 +Node: Feature History1065568 +Node: Common Extensions1078666 +Node: Ranges and Locales1080038 +Ref: Ranges and Locales-Footnote-11084657 +Ref: Ranges and Locales-Footnote-21084684 +Ref: Ranges and Locales-Footnote-31084919 +Node: Contributors1085140 +Node: History summary1090680 +Node: Installation1092059 +Node: Gawk Distribution1093005 +Node: Getting1093489 +Node: Extracting1094312 +Node: Distribution contents1095949 +Node: Unix Installation1101703 +Node: Quick Installation1102320 +Node: Additional Configuration Options1104744 +Node: Configuration Philosophy1106547 +Node: Non-Unix Installation1108916 +Node: PC Installation1109374 +Node: PC Binary Installation1110694 +Node: PC Compiling1112542 +Ref: PC Compiling-Footnote-11115563 +Node: PC Testing1115672 +Node: PC Using1116848 +Node: Cygwin1120963 +Node: MSYS1121733 +Node: VMS Installation1122234 +Node: VMS Compilation1123026 +Ref: VMS Compilation-Footnote-11124255 +Node: VMS Dynamic Extensions1124313 +Node: VMS Installation Details1125997 +Node: VMS Running1128248 +Node: VMS GNV1131088 +Node: VMS Old Gawk1131823 +Node: Bugs1132293 +Node: Other Versions1136182 +Node: Installation summary1142616 +Node: Notes1143675 +Node: Compatibility Mode1144540 +Node: Additions1145322 +Node: Accessing The Source1146247 +Node: Adding Code1147682 +Node: New Ports1153839 +Node: Derived Files1158321 +Ref: Derived Files-Footnote-11163796 +Ref: Derived Files-Footnote-21163830 +Ref: Derived Files-Footnote-31164426 +Node: Future Extensions1164540 +Node: Implementation Limitations1165146 +Node: Extension Design1166394 +Node: Old Extension Problems1167548 +Ref: Old Extension Problems-Footnote-11169065 +Node: Extension New Mechanism Goals1169122 +Ref: Extension New Mechanism Goals-Footnote-11172482 +Node: Extension Other Design Decisions1172671 +Node: Extension Future Growth1174779 +Node: Old Extension Mechanism1175615 +Node: Notes summary1177377 +Node: Basic Concepts1178563 +Node: Basic High Level1179244 +Ref: figure-general-flow1179516 +Ref: figure-process-flow1180115 +Ref: Basic High Level-Footnote-11183344 +Node: Basic Data Typing1183529 +Node: Glossary1186857 +Node: Copying1218786 +Node: GNU Free Documentation License1256342 +Node: Index1281478 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 80f8528d..d23b2128 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -20344,10 +20344,23 @@ Remember that you must supply a leading @samp{@@} in front of an indirect functi Starting with @value{PVERSION} 4.1.2 of @command{gawk}, indirect function calls may also be used with built-in functions and with extension functions -(@pxref{Dynamic Extensions}). The only thing you cannot do is pass a regular -expression constant to a built-in function through an indirect function -call.@footnote{This may change in a future version; recheck the documentation that -comes with your version of @command{gawk} to see if it has.} +(@pxref{Dynamic Extensions}). There are some limitations when calling +built-in functions indirectly, as follows. + +@itemize @value{BULLET} +@item +You cannot pass a regular expression constant to a built-in function +through an indirect function call.@footnote{This may change in a future +version; recheck the documentation that comes with your version of +@command{gawk} to see if it has.} This applies to the @code{sub()}, +@code{gsub()}, @code{gensub()}, @code{match()}, @code{split()} and +@code{patsplit()} functions. + +@item +If calling @code{sub()} or @code{gsub()}, you may only pass two arguments, +since those functions are unusual in that they update their third argument. +This means that @code{$0} will be updated. +@end itemize @command{gawk} does its best to make indirect function calls efficient. For example, in the following case: diff --git a/doc/gawktexi.in b/doc/gawktexi.in index cf669976..8e7d4010 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -19465,10 +19465,23 @@ Remember that you must supply a leading @samp{@@} in front of an indirect functi Starting with @value{PVERSION} 4.1.2 of @command{gawk}, indirect function calls may also be used with built-in functions and with extension functions -(@pxref{Dynamic Extensions}). The only thing you cannot do is pass a regular -expression constant to a built-in function through an indirect function -call.@footnote{This may change in a future version; recheck the documentation that -comes with your version of @command{gawk} to see if it has.} +(@pxref{Dynamic Extensions}). There are some limitations when calling +built-in functions indirectly, as follows. + +@itemize @value{BULLET} +@item +You cannot pass a regular expression constant to a built-in function +through an indirect function call.@footnote{This may change in a future +version; recheck the documentation that comes with your version of +@command{gawk} to see if it has.} This applies to the @code{sub()}, +@code{gsub()}, @code{gensub()}, @code{match()}, @code{split()} and +@code{patsplit()} functions. + +@item +If calling @code{sub()} or @code{gsub()}, you may only pass two arguments, +since those functions are unusual in that they update their third argument. +This means that @code{$0} will be updated. +@end itemize @command{gawk} does its best to make indirect function calls efficient. For example, in the following case: @@ -1180,7 +1180,7 @@ r_get_lhs(NODE *n, bool reference) /* r_get_field --- get the address of a field node */ -static inline NODE ** +NODE ** r_get_field(NODE *n, Func_ptr *assign, bool reference) { long field_num; diff --git a/interpret.h b/interpret.h index 372679df..55109063 100644 --- a/interpret.h +++ b/interpret.h @@ -1066,7 +1066,15 @@ match_re: assert(the_func != NULL); /* call it */ - r = the_func(arg_count); + if (the_func == (builtin_func_t) do_sub) + r = call_sub(t1->stptr, arg_count); + else if (the_func == do_match) + r = call_match(arg_count); + else if (the_func == do_split || the_func == do_patsplit) + r = call_split_func(t1->stptr, arg_count); + else + r = the_func(arg_count); + PUSH(r); break; } else if (f->type != Node_func) { diff --git a/test/ChangeLog b/test/ChangeLog index 862b8491..292e9615 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,12 @@ +2015-03-31 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am (indirectbuiltin): New test. + * indirectbuiltin.awk, indirectbuiltin.ok: New files. + +2015-03-24 Arnold D. Robbins <arnold@skeeve.com> + + * id.ok: Update after fixes in code. + 2015-03-24 Andrew J. Schorr <aschorr@telemetry-investments.com> * Makefile.am (EXTRA_DIST): Add exitval3.awk and exitval3.ok. diff --git a/test/Makefile.am b/test/Makefile.am index 1b5a2a50..515a26e2 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -431,6 +431,8 @@ EXTRA_DIST = \ include.awk \ include.ok \ include2.ok \ + indirectbuiltin.awk \ + indirectbuiltin.ok \ indirectcall.awk \ indirectcall.in \ indirectcall.ok \ @@ -1045,7 +1047,7 @@ GAWK_EXT_TESTS = \ genpot gensub gensub2 getlndir gnuops2 gnuops3 gnureops \ icasefs icasers id igncdym igncfs ignrcas2 ignrcase \ incdupe incdupe2 incdupe3 incdupe4 incdupe5 incdupe6 incdupe7 \ - include include2 indirectcall indirectcall2 \ + include include2 indirectbuiltin indirectcall indirectcall2 \ lint lintold lintwarn \ manyfiles match1 match2 match3 mbstr1 \ nastyparm next nondec nondec2 \ diff --git a/test/Makefile.in b/test/Makefile.in index d5f39447..17b28200 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -688,6 +688,8 @@ EXTRA_DIST = \ include.awk \ include.ok \ include2.ok \ + indirectbuiltin.awk \ + indirectbuiltin.ok \ indirectcall.awk \ indirectcall.in \ indirectcall.ok \ @@ -1301,7 +1303,7 @@ GAWK_EXT_TESTS = \ genpot gensub gensub2 getlndir gnuops2 gnuops3 gnureops \ icasefs icasers id igncdym igncfs ignrcas2 ignrcase \ incdupe incdupe2 incdupe3 incdupe4 incdupe5 incdupe6 incdupe7 \ - include include2 indirectcall indirectcall2 \ + include include2 indirectbuiltin indirectcall indirectcall2 \ lint lintold lintwarn \ manyfiles match1 match2 match3 mbstr1 \ nastyparm next nondec nondec2 \ @@ -3593,6 +3595,11 @@ include: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +indirectbuiltin: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + indirectcall: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index 58a1d670..5ee49061 100644 --- a/test/Maketests +++ b/test/Maketests @@ -1112,6 +1112,11 @@ include: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +indirectbuiltin: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + indirectcall: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @@ -14,6 +14,7 @@ sprintf -> builtin ROUNDMODE -> scalar strftime -> builtin systime -> builtin +length -> builtin and -> builtin srand -> builtin FNR -> scalar diff --git a/test/indirectbuiltin.awk b/test/indirectbuiltin.awk new file mode 100644 index 00000000..4d5291d2 --- /dev/null +++ b/test/indirectbuiltin.awk @@ -0,0 +1,371 @@ +function print_result(category, fname, builtin_result, indirect_result) +{ + if (builtin_result == indirect_result) + printf("%s: %s: pass\n", category, fname) + else { + printf("%s: %s: fail: builtin: %s \tindirect: %s\n", category, fname, + builtin_result, indirect_result) + exit 1 + } +} + + +BEGIN { +# math functions + + fun = "and" + b1 = and(0x11, 0x01) + i1 = @fun(0x11, 0x01) + print_result("math", fun, b1, i1) + + fun = "atan2" + b1 = atan2(-1, 0) + i1 = @fun(-1, 0) + print_result("math", fun, b1, i1) + + fun = "compl" + b1 = compl(0x1111) + i1 = @fun(0x1111) + print_result("math", fun, b1, i1) + + fun = "cos" + b1 = cos(3.1415927 / 4) + i1 = @fun(3.1415927 / 4) + print_result("math", fun, b1, i1) + + fun = "exp" + b1 = exp(2) + i1 = @fun(2) + print_result("math", fun, b1, i1) + + fun = "int" + b1 = int(3.1415927) + i1 = @fun(3.1415927) + print_result("math", fun, b1, i1) + + fun = "log" + b1 = log(10) + i1 = @fun(10) + print_result("math", fun, b1, i1) + + fun = "lshift" + b1 = lshift(1, 2) + i1 = @fun(1, 2) + print_result("math", fun, b1, i1) + + fun = "or" + b1 = or(0x10, 0x01) + i1 = @fun(0x10, 0x01) + print_result("math", fun, b1, i1) + + fun = "rand" + srand(1) + b1 = rand(); + srand(1) + i1 = @fun() + print_result("math", fun, b1, i1) + + fun = "rshift" + b1 = rshift(0x10, 1) + i1 = @fun(0x10, 1) + print_result("math", fun, b1, i1) + + fun = "sin" + b1 = sin(3.1415927 / 4) + i1 = @fun(3.1415927 / 4) + print_result("math", fun, b1, i1) + + fun = "sqrt" + b1 = sqrt(2) + i1 = @fun(2) + print_result("math", fun, b1, i1) + + srand() + fun = "srand" + b1 = srand() + i1 = @fun() + print_result("math", fun, b1, i1) + + fun = "xor" + b1 = xor(0x11, 0x01) + i1 = @fun(0x11, 0x01) + print_result("math", fun, b1, i1) + +# string functions + + fun = "gensub" + b1 = gensub("f", "q", "g", "ff11bb") + i1 = @fun("f", "q", "g", "ff11bb") + print_result("string", fun, b1, i1) + + fun = "gsub" + $0 = "ff11bb" + b1 = gsub("f", "q") + b2 = $0 + $0 = "ff11bb" + i1 = @fun("f", "q") + i2 = $0 + print_result("string", fun, b1, i1) + if (b2 != i2) { + printf("string: %s: fail: $0 (%s) != $0 (%s)\n", + fun, b2, i2) + exit 1 + } + + fun = "index" + b1 = index("hi, how are you", "how") + i1 = @fun("hi, how are you", "how") + print_result("string", fun, b1, i1) + + fun = "dcgettext" + b1 = dcgettext("hello, world") + i1 = @fun("hello, world") + print_result("string", fun, b1, i1) + + fun = "dcngettext" + b1 = dcngettext("hello, world", "howdy", 2) + i1 = @fun("hello, world", "howdy", 2) + print_result("string", fun, b1, i1) + + fun = "length" + b1 = length("hi, how are you") + i1 = @fun("hi, how are you") + print_result("string", fun, b1, i1) + + fun = "sprintf" + b1 = sprintf("%s world", "hello") + i1 = @fun("%s world", "hello") + print_result("string", fun, b1, i1) + + fun = "strtonum" + b1 = strtonum("0xdeadbeef") + i1 = @fun("0xdeadbeef") + print_result("string", fun, b1, i1) + + fun = "sub" + $0 = "ff11bb" + b1 = sub("f", "q") + b2 = $0 + $0 = "ff11bb" + i1 = @fun("f", "q") + i2 = $0 + print_result("string", fun, b1, i1) + if (b2 != i2) { + printf("string: %s: fail: $0 (%s) != $0 (%s)\n", + fun, b2, i2) + exit 1 + } + + fun = "substr" + b1 = substr("0xdeadbeef", 7, 4) + i1 = @fun("0xdeadbeef", 7, 4) + print_result("string", fun, b1, i1) + + fun = "tolower" + b1 = tolower("0xDeAdBeEf") + i1 = @fun("0xDeAdBeEf") + print_result("string", fun, b1, i1) + + fun = "toupper" + b1 = toupper("0xDeAdBeEf") + i1 = @fun("0xDeAdBeEf") + print_result("string", fun, b1, i1) + +# time functions + + fun = "mktime" + b1 = mktime("1990 02 11 12 00 00") + i1 = @fun("1990 02 11 12 00 00") + print_result("time", fun, b1, i1) + + then = b1 + fun = "strftime" + b1 = strftime(PROCINFO["strftime"], then) + i1 = @fun(PROCINFO["strftime"], then) + print_result("time", fun, b1, i1) + + fun = "systime" + b1 = systime() + i1 = @fun() + print_result("time", fun, b1, i1) + +# regexp functions + + fun = "match" + b1 = match("o+", "fooob") + rstart = RSTART + rlength = RLENGTH + i1 = @fun("o+", "fooob") + print_result("regexp", fun, b1, i1) + if (rstart != RSTART) { + printf("match: failure: biRSTART (%d) != iRSTART (%d)\n", + rstart, RSTART) + exit 1 + } + if (rlength != RLENGTH) { + printf("match: failure: biRLENGTH (%d) != iRLENGTH (%d)\n", + rlength, RLENGTH) + exit 1 + } + + ############## start patsplit ############## + fun = "patsplit" + delete data + delete data2 + delete seps + delete seps2 + b1 = patsplit("a:b:c:d", data, ":", seps) + i1 = @fun("a:b:c:d", data2, ":", seps2) + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("patsplit1a: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + for (i in seps) { + if ((! (i in seps2)) || seps[i] != seps2[i]) { + printf("patsplit1b: fail: builtin seps[%d] (%s) != indirect seps[%d] (%s)\n", + i, seps[i], i, seps2[i]) + exit 1 + } + } + + fun = "patsplit" + delete data + delete data2 + b1 = patsplit("a:b:c:d", data, ":") + i1 = @fun("a:b:c:d", data2, ":") + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("patsplit2: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + + fun = "patsplit" + delete data + delete data2 + FPAT = "[a-z]+" + b1 = patsplit("a b c d", data) + i1 = @fun("a b c d", data2) + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("patsplit3: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + ############## end patsplit ############## + + ############## start split ############## + fun = "split" + delete data + delete data2 + delete seps + delete seps2 + b1 = split("a:b:c:d", data, ":", seps) + i1 = @fun("a:b:c:d", data2, ":", seps2) + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("split1a: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + for (i in seps) { + if ((! (i in seps2)) || seps[i] != seps2[i]) { + printf("split1b: fail: builtin seps[%d] (%s) != indirect seps[%d] (%s)\n", + i, seps[i], i, seps2[i]) + exit 1 + } + } + + fun = "split" + delete data + delete data2 + b1 = split("a:b:c:d", data, ":") + i1 = @fun("a:b:c:d", data2, ":") + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("split2: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + + fun = "split" + delete data + delete data2 + b1 = split("a b c d", data) + i1 = @fun("a b c d", data2) + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("split3: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + ############## end split ############## + +# array functions + + split("z y x w v u t", data) + fun = "asort" + asort(data, newdata) + @fun(data, newdata2) + print_result("array", fun, b1, i1) + for (i in newdata) { + if (! (i in newdata2) || newdata[i] != newdata2[i]) { + print fun ": failed, index", i + exit + } + } + + for (i in data) + data2[data[i]] = i + + fun = "asorti" + asorti(data2, newdata) + @fun(data2, newdata2) + print_result("array", fun, b1, i1) + for (i in newdata) { + if (! (i in newdata2) || newdata[i] != newdata2[i]) { + print fun ": failed, index", i, "value", newdata[i], newdata2[i] + exit + } + } + + arr[1] = arr[2] = 42 + fun = "isarray" + b1 = isarray(arr) + i1 = @fun(arr) + print_result("array", fun, b1, i1) + +# i/o functions + + print("hi") > "x1.out" + print("hi") > "x2.out" + + fun = "fflush" + b1 = fflush("x1.out") + i1 = @fun("x2.out") + print_result("i/o", fun, b1, i1) + + fun = "close" + b1 = close("x1.out") + i1 = @fun("x2.out") + print_result("i/o", fun, b1, i1) + + fun = "system" + b1 = system("rm x1.out") + i1 = @fun("rm x2.out") + print_result("i/o", fun, b1, i1) +} diff --git a/test/indirectbuiltin.ok b/test/indirectbuiltin.ok new file mode 100644 index 00000000..312bbd76 --- /dev/null +++ b/test/indirectbuiltin.ok @@ -0,0 +1,43 @@ +math: and: pass +math: atan2: pass +math: compl: pass +math: cos: pass +math: exp: pass +math: int: pass +math: log: pass +math: lshift: pass +math: or: pass +math: rand: pass +math: rshift: pass +math: sin: pass +math: sqrt: pass +math: srand: pass +math: xor: pass +string: gensub: pass +string: gsub: pass +string: index: pass +string: dcgettext: pass +string: dcngettext: pass +string: length: pass +string: sprintf: pass +string: strtonum: pass +string: sub: pass +string: substr: pass +string: tolower: pass +string: toupper: pass +time: mktime: pass +time: strftime: pass +time: systime: pass +regexp: match: pass +regexp: patsplit: pass +regexp: patsplit: pass +regexp: patsplit: pass +regexp: split: pass +regexp: split: pass +regexp: split: pass +array: asort: pass +array: asorti: pass +array: isarray: pass +i/o: fflush: pass +i/o: close: pass +i/o: system: pass |