summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-03-31 22:32:44 +0300
committerArnold D. Robbins <arnold@skeeve.com>2015-03-31 22:32:44 +0300
commit902b25a40d5cc612dd7a0becb27a5a48afa49716 (patch)
treeb4baae3a4d846d0bd60251c28ebf77dde2189573
parent2bdaa6b89e00984d79305ba1066cf98c5674b556 (diff)
parent9730efeabb2116fdf7e93b4553825ba147f5f523 (diff)
downloadgawk-902b25a40d5cc612dd7a0becb27a5a48afa49716.tar.gz
Merge branch 'gawk-4.1-stable'
-rw-r--r--ChangeLog36
-rw-r--r--awk.h5
-rw-r--r--awkgram.c739
-rw-r--r--awkgram.y21
-rw-r--r--builtin.c140
-rw-r--r--doc/ChangeLog4
-rw-r--r--doc/gawk.info676
-rw-r--r--doc/gawk.texi25
-rw-r--r--doc/gawktexi.in25
-rw-r--r--eval.c2
-rw-r--r--interpret.h10
-rw-r--r--test/ChangeLog9
-rw-r--r--test/Makefile.am4
-rw-r--r--test/Makefile.in9
-rw-r--r--test/Maketests5
-rw-r--r--test/id.ok1
-rw-r--r--test/indirectbuiltin.awk371
-rw-r--r--test/indirectbuiltin.ok43
18 files changed, 1407 insertions, 718 deletions
diff --git a/ChangeLog b/ChangeLog
index b2e0214d..9b2490bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,34 @@
+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-27 Arnold D. Robbins <arnold@skeeve.com>
* io.c (redirect): Change not_string from int to bool.
* gawkapi.c (api_get_file): Minor stylistic improvements.
* NEWS: Updated for retryable I/O and new API function.
+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
@@ -13,6 +38,17 @@
* awk.h, gawkapi.c, io.c: Minor code reformatting.
+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().
+
2015-03-18 Arnold D. Robbins <arnold@skeeve.com>
* config.guess, config.sub: Updated, from libtool 2.4.6.
diff --git a/awk.h b/awk.h
index 6b9ac10b..384e6f16 100644
--- a/awk.h
+++ b/awk.h
@@ -1338,6 +1338,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);
@@ -1367,6 +1368,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);
@@ -1414,6 +1418,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 */
diff --git a/awkgram.c b/awkgram.c
index 78e915ac..40f5d286 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -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);
@@ -203,7 +202,7 @@ extern double fmod(double x, double y);
#define YYSTYPE INSTRUCTION *
-#line 207 "awkgram.c" /* yacc.c:339 */
+#line 206 "awkgram.c" /* yacc.c:339 */
# ifndef YY_NULLPTR
# if defined __cplusplus && 201103L <= __cplusplus
@@ -357,7 +356,7 @@ int yyparse (void);
/* Copy the second part of user declarations. */
-#line 361 "awkgram.c" /* yacc.c:358 */
+#line 360 "awkgram.c" /* yacc.c:358 */
#ifdef short
# undef short
@@ -659,25 +658,25 @@ static const yytype_uint8 yytranslate[] =
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 206, 206, 208, 213, 214, 218, 230, 235, 246,
- 252, 258, 267, 275, 277, 282, 290, 292, 298, 306,
- 316, 346, 360, 374, 382, 393, 405, 407, 409, 415,
- 423, 424, 428, 463, 462, 496, 498, 503, 509, 537,
- 542, 543, 547, 549, 551, 558, 648, 690, 732, 845,
- 852, 859, 869, 878, 887, 896, 907, 923, 922, 946,
- 958, 958, 1056, 1056, 1089, 1119, 1125, 1126, 1132, 1133,
- 1140, 1145, 1157, 1171, 1173, 1181, 1186, 1188, 1196, 1198,
- 1207, 1208, 1216, 1221, 1221, 1232, 1236, 1244, 1245, 1248,
- 1250, 1255, 1256, 1265, 1266, 1271, 1276, 1282, 1284, 1286,
- 1293, 1294, 1300, 1301, 1306, 1308, 1313, 1315, 1323, 1328,
- 1337, 1344, 1346, 1348, 1364, 1374, 1381, 1383, 1388, 1390,
- 1392, 1400, 1402, 1407, 1409, 1414, 1416, 1418, 1468, 1470,
- 1472, 1474, 1476, 1478, 1480, 1482, 1496, 1501, 1506, 1531,
- 1537, 1539, 1541, 1543, 1545, 1547, 1552, 1556, 1588, 1590,
- 1596, 1602, 1615, 1616, 1617, 1622, 1627, 1631, 1635, 1650,
- 1663, 1668, 1705, 1734, 1735, 1741, 1742, 1747, 1749, 1756,
- 1773, 1790, 1792, 1799, 1804, 1812, 1822, 1834, 1843, 1847,
- 1851, 1855, 1859, 1863, 1866, 1868, 1872, 1876, 1880
+ 0, 205, 205, 207, 212, 213, 217, 229, 234, 245,
+ 251, 257, 266, 274, 276, 281, 289, 291, 297, 305,
+ 315, 345, 359, 373, 381, 392, 404, 406, 408, 414,
+ 422, 423, 427, 462, 461, 495, 497, 502, 508, 536,
+ 541, 542, 546, 548, 550, 557, 647, 689, 731, 844,
+ 851, 858, 868, 877, 886, 895, 906, 922, 921, 945,
+ 957, 957, 1055, 1055, 1088, 1118, 1124, 1125, 1131, 1132,
+ 1139, 1144, 1156, 1170, 1172, 1180, 1185, 1187, 1195, 1197,
+ 1206, 1207, 1215, 1220, 1220, 1231, 1235, 1243, 1244, 1247,
+ 1249, 1254, 1255, 1264, 1265, 1270, 1275, 1281, 1283, 1285,
+ 1292, 1293, 1299, 1300, 1305, 1307, 1312, 1314, 1322, 1327,
+ 1336, 1343, 1345, 1347, 1363, 1373, 1380, 1382, 1387, 1389,
+ 1391, 1399, 1401, 1406, 1408, 1413, 1415, 1417, 1467, 1469,
+ 1471, 1473, 1475, 1477, 1479, 1481, 1495, 1500, 1505, 1530,
+ 1536, 1538, 1540, 1542, 1544, 1546, 1551, 1555, 1587, 1589,
+ 1595, 1601, 1614, 1615, 1616, 1621, 1626, 1630, 1634, 1649,
+ 1662, 1667, 1704, 1733, 1734, 1740, 1741, 1746, 1748, 1755,
+ 1772, 1789, 1791, 1798, 1803, 1811, 1821, 1833, 1842, 1846,
+ 1850, 1854, 1858, 1862, 1865, 1867, 1871, 1875, 1879
};
#endif
@@ -1850,24 +1849,24 @@ yyreduce:
switch (yyn)
{
case 3:
-#line 209 "awkgram.y" /* yacc.c:1646 */
+#line 208 "awkgram.y" /* yacc.c:1646 */
{
rule = 0;
yyerrok;
}
-#line 1859 "awkgram.c" /* yacc.c:1646 */
+#line 1858 "awkgram.c" /* yacc.c:1646 */
break;
case 5:
-#line 215 "awkgram.y" /* yacc.c:1646 */
+#line 214 "awkgram.y" /* yacc.c:1646 */
{
next_sourcefile();
}
-#line 1867 "awkgram.c" /* yacc.c:1646 */
+#line 1866 "awkgram.c" /* yacc.c:1646 */
break;
case 6:
-#line 219 "awkgram.y" /* yacc.c:1646 */
+#line 218 "awkgram.y" /* yacc.c:1646 */
{
rule = 0;
/*
@@ -1876,20 +1875,20 @@ yyreduce:
*/
/* yyerrok; */
}
-#line 1880 "awkgram.c" /* yacc.c:1646 */
+#line 1879 "awkgram.c" /* yacc.c:1646 */
break;
case 7:
-#line 231 "awkgram.y" /* yacc.c:1646 */
+#line 230 "awkgram.y" /* yacc.c:1646 */
{
(void) append_rule((yyvsp[-1]), (yyvsp[0]));
first_rule = false;
}
-#line 1889 "awkgram.c" /* yacc.c:1646 */
+#line 1888 "awkgram.c" /* yacc.c:1646 */
break;
case 8:
-#line 236 "awkgram.y" /* yacc.c:1646 */
+#line 235 "awkgram.y" /* yacc.c:1646 */
{
if (rule != Rule) {
msg(_("%s blocks must have an action part"), ruletab[rule]);
@@ -1900,41 +1899,41 @@ yyreduce:
} else /* pattern rule with non-empty pattern */
(void) append_rule((yyvsp[-1]), NULL);
}
-#line 1904 "awkgram.c" /* yacc.c:1646 */
+#line 1903 "awkgram.c" /* yacc.c:1646 */
break;
case 9:
-#line 247 "awkgram.y" /* yacc.c:1646 */
+#line 246 "awkgram.y" /* yacc.c:1646 */
{
in_function = NULL;
(void) mk_function((yyvsp[-1]), (yyvsp[0]));
yyerrok;
}
-#line 1914 "awkgram.c" /* yacc.c:1646 */
+#line 1913 "awkgram.c" /* yacc.c:1646 */
break;
case 10:
-#line 253 "awkgram.y" /* yacc.c:1646 */
+#line 252 "awkgram.y" /* yacc.c:1646 */
{
want_source = false;
at_seen = false;
yyerrok;
}
-#line 1924 "awkgram.c" /* yacc.c:1646 */
+#line 1923 "awkgram.c" /* yacc.c:1646 */
break;
case 11:
-#line 259 "awkgram.y" /* yacc.c:1646 */
+#line 258 "awkgram.y" /* yacc.c:1646 */
{
want_source = false;
at_seen = false;
yyerrok;
}
-#line 1934 "awkgram.c" /* yacc.c:1646 */
+#line 1933 "awkgram.c" /* yacc.c:1646 */
break;
case 12:
-#line 268 "awkgram.y" /* yacc.c:1646 */
+#line 267 "awkgram.y" /* yacc.c:1646 */
{
if (include_source((yyvsp[0])) < 0)
YYABORT;
@@ -1942,23 +1941,23 @@ yyreduce:
bcfree((yyvsp[0]));
(yyval) = NULL;
}
-#line 1946 "awkgram.c" /* yacc.c:1646 */
+#line 1945 "awkgram.c" /* yacc.c:1646 */
break;
case 13:
-#line 276 "awkgram.y" /* yacc.c:1646 */
+#line 275 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 1952 "awkgram.c" /* yacc.c:1646 */
+#line 1951 "awkgram.c" /* yacc.c:1646 */
break;
case 14:
-#line 278 "awkgram.y" /* yacc.c:1646 */
+#line 277 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 1958 "awkgram.c" /* yacc.c:1646 */
+#line 1957 "awkgram.c" /* yacc.c:1646 */
break;
case 15:
-#line 283 "awkgram.y" /* yacc.c:1646 */
+#line 282 "awkgram.y" /* yacc.c:1646 */
{
if (load_library((yyvsp[0])) < 0)
YYABORT;
@@ -1966,23 +1965,23 @@ yyreduce:
bcfree((yyvsp[0]));
(yyval) = NULL;
}
-#line 1970 "awkgram.c" /* yacc.c:1646 */
+#line 1969 "awkgram.c" /* yacc.c:1646 */
break;
case 16:
-#line 291 "awkgram.y" /* yacc.c:1646 */
+#line 290 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 1976 "awkgram.c" /* yacc.c:1646 */
+#line 1975 "awkgram.c" /* yacc.c:1646 */
break;
case 17:
-#line 293 "awkgram.y" /* yacc.c:1646 */
+#line 292 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 1982 "awkgram.c" /* yacc.c:1646 */
+#line 1981 "awkgram.c" /* yacc.c:1646 */
break;
case 18:
-#line 298 "awkgram.y" /* yacc.c:1646 */
+#line 297 "awkgram.y" /* yacc.c:1646 */
{
rule = Rule;
if (comment != NULL) {
@@ -1991,11 +1990,11 @@ yyreduce:
} else
(yyval) = NULL;
}
-#line 1995 "awkgram.c" /* yacc.c:1646 */
+#line 1994 "awkgram.c" /* yacc.c:1646 */
break;
case 19:
-#line 307 "awkgram.y" /* yacc.c:1646 */
+#line 306 "awkgram.y" /* yacc.c:1646 */
{
rule = Rule;
if (comment != NULL) {
@@ -2004,11 +2003,11 @@ yyreduce:
} else
(yyval) = (yyvsp[0]);
}
-#line 2008 "awkgram.c" /* yacc.c:1646 */
+#line 2007 "awkgram.c" /* yacc.c:1646 */
break;
case 20:
-#line 317 "awkgram.y" /* yacc.c:1646 */
+#line 316 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *tp;
@@ -2038,11 +2037,11 @@ yyreduce:
(yyval) = list_append(list_merge((yyvsp[-3]), (yyvsp[0])), tp);
rule = Rule;
}
-#line 2042 "awkgram.c" /* yacc.c:1646 */
+#line 2041 "awkgram.c" /* yacc.c:1646 */
break;
case 21:
-#line 347 "awkgram.y" /* yacc.c:1646 */
+#line 346 "awkgram.y" /* yacc.c:1646 */
{
static int begin_seen = 0;
@@ -2056,11 +2055,11 @@ yyreduce:
check_comment();
(yyval) = (yyvsp[0]);
}
-#line 2060 "awkgram.c" /* yacc.c:1646 */
+#line 2059 "awkgram.c" /* yacc.c:1646 */
break;
case 22:
-#line 361 "awkgram.y" /* yacc.c:1646 */
+#line 360 "awkgram.y" /* yacc.c:1646 */
{
static int end_seen = 0;
@@ -2074,11 +2073,11 @@ yyreduce:
check_comment();
(yyval) = (yyvsp[0]);
}
-#line 2078 "awkgram.c" /* yacc.c:1646 */
+#line 2077 "awkgram.c" /* yacc.c:1646 */
break;
case 23:
-#line 375 "awkgram.y" /* yacc.c:1646 */
+#line 374 "awkgram.y" /* yacc.c:1646 */
{
func_first = false;
(yyvsp[0])->in_rule = rule = BEGINFILE;
@@ -2086,11 +2085,11 @@ yyreduce:
check_comment();
(yyval) = (yyvsp[0]);
}
-#line 2090 "awkgram.c" /* yacc.c:1646 */
+#line 2089 "awkgram.c" /* yacc.c:1646 */
break;
case 24:
-#line 383 "awkgram.y" /* yacc.c:1646 */
+#line 382 "awkgram.y" /* yacc.c:1646 */
{
func_first = false;
(yyvsp[0])->in_rule = rule = ENDFILE;
@@ -2098,11 +2097,11 @@ yyreduce:
check_comment();
(yyval) = (yyvsp[0]);
}
-#line 2102 "awkgram.c" /* yacc.c:1646 */
+#line 2101 "awkgram.c" /* yacc.c:1646 */
break;
case 25:
-#line 394 "awkgram.y" /* yacc.c:1646 */
+#line 393 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *ip;
if ((yyvsp[-3]) == NULL)
@@ -2111,42 +2110,42 @@ yyreduce:
ip = (yyvsp[-3]);
(yyval) = ip;
}
-#line 2115 "awkgram.c" /* yacc.c:1646 */
+#line 2114 "awkgram.c" /* yacc.c:1646 */
break;
case 26:
-#line 406 "awkgram.y" /* yacc.c:1646 */
+#line 405 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 2121 "awkgram.c" /* yacc.c:1646 */
+#line 2120 "awkgram.c" /* yacc.c:1646 */
break;
case 27:
-#line 408 "awkgram.y" /* yacc.c:1646 */
+#line 407 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 2127 "awkgram.c" /* yacc.c:1646 */
+#line 2126 "awkgram.c" /* yacc.c:1646 */
break;
case 28:
-#line 410 "awkgram.y" /* yacc.c:1646 */
+#line 409 "awkgram.y" /* yacc.c:1646 */
{
yyerror(_("`%s' is a built-in function, it cannot be redefined"),
tokstart);
YYABORT;
}
-#line 2137 "awkgram.c" /* yacc.c:1646 */
+#line 2136 "awkgram.c" /* yacc.c:1646 */
break;
case 29:
-#line 416 "awkgram.y" /* yacc.c:1646 */
+#line 415 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = (yyvsp[0]);
at_seen = false;
}
-#line 2146 "awkgram.c" /* yacc.c:1646 */
+#line 2145 "awkgram.c" /* yacc.c:1646 */
break;
case 32:
-#line 429 "awkgram.y" /* yacc.c:1646 */
+#line 428 "awkgram.y" /* yacc.c:1646 */
{
/*
* treat any comments between BOF and the first function
@@ -2173,17 +2172,17 @@ yyreduce:
/* $4 already free'd in install_function */
(yyval) = (yyvsp[-5]);
}
-#line 2177 "awkgram.c" /* yacc.c:1646 */
+#line 2176 "awkgram.c" /* yacc.c:1646 */
break;
case 33:
-#line 463 "awkgram.y" /* yacc.c:1646 */
+#line 462 "awkgram.y" /* yacc.c:1646 */
{ want_regexp = true; }
-#line 2183 "awkgram.c" /* yacc.c:1646 */
+#line 2182 "awkgram.c" /* yacc.c:1646 */
break;
case 34:
-#line 465 "awkgram.y" /* yacc.c:1646 */
+#line 464 "awkgram.y" /* yacc.c:1646 */
{
NODE *n, *exp;
char *re;
@@ -2212,28 +2211,28 @@ yyreduce:
(yyval)->opcode = Op_match_rec;
(yyval)->memory = n;
}
-#line 2216 "awkgram.c" /* yacc.c:1646 */
+#line 2215 "awkgram.c" /* yacc.c:1646 */
break;
case 35:
-#line 497 "awkgram.y" /* yacc.c:1646 */
+#line 496 "awkgram.y" /* yacc.c:1646 */
{ bcfree((yyvsp[0])); }
-#line 2222 "awkgram.c" /* yacc.c:1646 */
+#line 2221 "awkgram.c" /* yacc.c:1646 */
break;
case 37:
-#line 503 "awkgram.y" /* yacc.c:1646 */
+#line 502 "awkgram.y" /* yacc.c:1646 */
{
if (comment != NULL) {
(yyval) = list_create(comment);
comment = NULL;
} else (yyval) = NULL;
}
-#line 2233 "awkgram.c" /* yacc.c:1646 */
+#line 2232 "awkgram.c" /* yacc.c:1646 */
break;
case 38:
-#line 510 "awkgram.y" /* yacc.c:1646 */
+#line 509 "awkgram.y" /* yacc.c:1646 */
{
if ((yyvsp[0]) == NULL) {
if (comment == NULL)
@@ -2261,40 +2260,40 @@ yyreduce:
}
yyerrok;
}
-#line 2265 "awkgram.c" /* yacc.c:1646 */
+#line 2264 "awkgram.c" /* yacc.c:1646 */
break;
case 39:
-#line 538 "awkgram.y" /* yacc.c:1646 */
+#line 537 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 2271 "awkgram.c" /* yacc.c:1646 */
+#line 2270 "awkgram.c" /* yacc.c:1646 */
break;
case 42:
-#line 548 "awkgram.y" /* yacc.c:1646 */
+#line 547 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 2277 "awkgram.c" /* yacc.c:1646 */
+#line 2276 "awkgram.c" /* yacc.c:1646 */
break;
case 43:
-#line 550 "awkgram.y" /* yacc.c:1646 */
+#line 549 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[-1]); }
-#line 2283 "awkgram.c" /* yacc.c:1646 */
+#line 2282 "awkgram.c" /* yacc.c:1646 */
break;
case 44:
-#line 552 "awkgram.y" /* yacc.c:1646 */
+#line 551 "awkgram.y" /* yacc.c:1646 */
{
if (do_pretty_print)
(yyval) = list_prepend((yyvsp[0]), instruction(Op_exec_count));
else
(yyval) = (yyvsp[0]);
}
-#line 2294 "awkgram.c" /* yacc.c:1646 */
+#line 2293 "awkgram.c" /* yacc.c:1646 */
break;
case 45:
-#line 559 "awkgram.y" /* yacc.c:1646 */
+#line 558 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *dflt, *curr = NULL, *cexp, *cstmt;
INSTRUCTION *ip, *nextc, *tbreak;
@@ -2384,11 +2383,11 @@ yyreduce:
break_allowed--;
fix_break_continue(ip, tbreak, NULL);
}
-#line 2388 "awkgram.c" /* yacc.c:1646 */
+#line 2387 "awkgram.c" /* yacc.c:1646 */
break;
case 46:
-#line 649 "awkgram.y" /* yacc.c:1646 */
+#line 648 "awkgram.y" /* yacc.c:1646 */
{
/*
* -----------------
@@ -2430,11 +2429,11 @@ yyreduce:
continue_allowed--;
fix_break_continue(ip, tbreak, tcont);
}
-#line 2434 "awkgram.c" /* yacc.c:1646 */
+#line 2433 "awkgram.c" /* yacc.c:1646 */
break;
case 47:
-#line 691 "awkgram.y" /* yacc.c:1646 */
+#line 690 "awkgram.y" /* yacc.c:1646 */
{
/*
* -----------------
@@ -2476,11 +2475,11 @@ yyreduce:
} /* else
$1 and $4 are NULLs */
}
-#line 2480 "awkgram.c" /* yacc.c:1646 */
+#line 2479 "awkgram.c" /* yacc.c:1646 */
break;
case 48:
-#line 733 "awkgram.y" /* yacc.c:1646 */
+#line 732 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *ip;
char *var_name = (yyvsp[-5])->lextok;
@@ -2593,44 +2592,44 @@ regular_loop:
break_allowed--;
continue_allowed--;
}
-#line 2597 "awkgram.c" /* yacc.c:1646 */
+#line 2596 "awkgram.c" /* yacc.c:1646 */
break;
case 49:
-#line 846 "awkgram.y" /* yacc.c:1646 */
+#line 845 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = mk_for_loop((yyvsp[-11]), (yyvsp[-9]), (yyvsp[-6]), (yyvsp[-3]), (yyvsp[0]));
break_allowed--;
continue_allowed--;
}
-#line 2608 "awkgram.c" /* yacc.c:1646 */
+#line 2607 "awkgram.c" /* yacc.c:1646 */
break;
case 50:
-#line 853 "awkgram.y" /* yacc.c:1646 */
+#line 852 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = mk_for_loop((yyvsp[-10]), (yyvsp[-8]), (INSTRUCTION *) NULL, (yyvsp[-3]), (yyvsp[0]));
break_allowed--;
continue_allowed--;
}
-#line 2619 "awkgram.c" /* yacc.c:1646 */
+#line 2618 "awkgram.c" /* yacc.c:1646 */
break;
case 51:
-#line 860 "awkgram.y" /* yacc.c:1646 */
+#line 859 "awkgram.y" /* yacc.c:1646 */
{
if (do_pretty_print)
(yyval) = list_prepend((yyvsp[0]), instruction(Op_exec_count));
else
(yyval) = (yyvsp[0]);
}
-#line 2630 "awkgram.c" /* yacc.c:1646 */
+#line 2629 "awkgram.c" /* yacc.c:1646 */
break;
case 52:
-#line 870 "awkgram.y" /* yacc.c:1646 */
+#line 869 "awkgram.y" /* yacc.c:1646 */
{
if (! break_allowed)
error_ln((yyvsp[-1])->source_line,
@@ -2639,11 +2638,11 @@ regular_loop:
(yyval) = list_create((yyvsp[-1]));
}
-#line 2643 "awkgram.c" /* yacc.c:1646 */
+#line 2642 "awkgram.c" /* yacc.c:1646 */
break;
case 53:
-#line 879 "awkgram.y" /* yacc.c:1646 */
+#line 878 "awkgram.y" /* yacc.c:1646 */
{
if (! continue_allowed)
error_ln((yyvsp[-1])->source_line,
@@ -2652,11 +2651,11 @@ regular_loop:
(yyval) = list_create((yyvsp[-1]));
}
-#line 2656 "awkgram.c" /* yacc.c:1646 */
+#line 2655 "awkgram.c" /* yacc.c:1646 */
break;
case 54:
-#line 888 "awkgram.y" /* yacc.c:1646 */
+#line 887 "awkgram.y" /* yacc.c:1646 */
{
/* if inside function (rule = 0), resolve context at run-time */
if (rule && rule != Rule)
@@ -2665,11 +2664,11 @@ regular_loop:
(yyvsp[-1])->target_jmp = ip_rec;
(yyval) = list_create((yyvsp[-1]));
}
-#line 2669 "awkgram.c" /* yacc.c:1646 */
+#line 2668 "awkgram.c" /* yacc.c:1646 */
break;
case 55:
-#line 897 "awkgram.y" /* yacc.c:1646 */
+#line 896 "awkgram.y" /* yacc.c:1646 */
{
/* if inside function (rule = 0), resolve context at run-time */
if (rule == BEGIN || rule == END || rule == ENDFILE)
@@ -2680,11 +2679,11 @@ regular_loop:
(yyvsp[-1])->target_endfile = ip_endfile;
(yyval) = list_create((yyvsp[-1]));
}
-#line 2684 "awkgram.c" /* yacc.c:1646 */
+#line 2683 "awkgram.c" /* yacc.c:1646 */
break;
case 56:
-#line 908 "awkgram.y" /* yacc.c:1646 */
+#line 907 "awkgram.y" /* yacc.c:1646 */
{
/* Initialize the two possible jump targets, the actual target
* is resolved at run-time.
@@ -2699,20 +2698,20 @@ regular_loop:
} else
(yyval) = list_append((yyvsp[-1]), (yyvsp[-2]));
}
-#line 2703 "awkgram.c" /* yacc.c:1646 */
+#line 2702 "awkgram.c" /* yacc.c:1646 */
break;
case 57:
-#line 923 "awkgram.y" /* yacc.c:1646 */
+#line 922 "awkgram.y" /* yacc.c:1646 */
{
if (! in_function)
yyerror(_("`return' used outside function context"));
}
-#line 2712 "awkgram.c" /* yacc.c:1646 */
+#line 2711 "awkgram.c" /* yacc.c:1646 */
break;
case 58:
-#line 926 "awkgram.y" /* yacc.c:1646 */
+#line 925 "awkgram.y" /* yacc.c:1646 */
{
if ((yyvsp[-1]) == NULL) {
(yyval) = list_create((yyvsp[-3]));
@@ -2733,17 +2732,17 @@ regular_loop:
(yyval) = list_append((yyvsp[-1]), (yyvsp[-3]));
}
}
-#line 2737 "awkgram.c" /* yacc.c:1646 */
+#line 2736 "awkgram.c" /* yacc.c:1646 */
break;
case 60:
-#line 958 "awkgram.y" /* yacc.c:1646 */
+#line 957 "awkgram.y" /* yacc.c:1646 */
{ in_print = true; in_parens = 0; }
-#line 2743 "awkgram.c" /* yacc.c:1646 */
+#line 2742 "awkgram.c" /* yacc.c:1646 */
break;
case 61:
-#line 959 "awkgram.y" /* yacc.c:1646 */
+#line 958 "awkgram.y" /* yacc.c:1646 */
{
/*
* Optimization: plain `print' has no expression list, so $3 is null.
@@ -2840,17 +2839,17 @@ regular_print:
}
}
}
-#line 2844 "awkgram.c" /* yacc.c:1646 */
+#line 2843 "awkgram.c" /* yacc.c:1646 */
break;
case 62:
-#line 1056 "awkgram.y" /* yacc.c:1646 */
+#line 1055 "awkgram.y" /* yacc.c:1646 */
{ sub_counter = 0; }
-#line 2850 "awkgram.c" /* yacc.c:1646 */
+#line 2849 "awkgram.c" /* yacc.c:1646 */
break;
case 63:
-#line 1057 "awkgram.y" /* yacc.c:1646 */
+#line 1056 "awkgram.y" /* yacc.c:1646 */
{
char *arr = (yyvsp[-2])->lextok;
@@ -2883,11 +2882,11 @@ regular_print:
(yyval) = list_append(list_append((yyvsp[0]), (yyvsp[-2])), (yyvsp[-3]));
}
}
-#line 2887 "awkgram.c" /* yacc.c:1646 */
+#line 2886 "awkgram.c" /* yacc.c:1646 */
break;
case 64:
-#line 1094 "awkgram.y" /* yacc.c:1646 */
+#line 1093 "awkgram.y" /* yacc.c:1646 */
{
static bool warned = false;
char *arr = (yyvsp[-1])->lextok;
@@ -2913,52 +2912,52 @@ regular_print:
fatal(_("`delete' is not allowed with FUNCTAB"));
}
}
-#line 2917 "awkgram.c" /* yacc.c:1646 */
+#line 2916 "awkgram.c" /* yacc.c:1646 */
break;
case 65:
-#line 1120 "awkgram.y" /* yacc.c:1646 */
+#line 1119 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = optimize_assignment((yyvsp[0])); }
-#line 2923 "awkgram.c" /* yacc.c:1646 */
+#line 2922 "awkgram.c" /* yacc.c:1646 */
break;
case 66:
-#line 1125 "awkgram.y" /* yacc.c:1646 */
+#line 1124 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 2929 "awkgram.c" /* yacc.c:1646 */
+#line 2928 "awkgram.c" /* yacc.c:1646 */
break;
case 67:
-#line 1127 "awkgram.y" /* yacc.c:1646 */
+#line 1126 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 2935 "awkgram.c" /* yacc.c:1646 */
+#line 2934 "awkgram.c" /* yacc.c:1646 */
break;
case 68:
-#line 1132 "awkgram.y" /* yacc.c:1646 */
+#line 1131 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 2941 "awkgram.c" /* yacc.c:1646 */
+#line 2940 "awkgram.c" /* yacc.c:1646 */
break;
case 69:
-#line 1134 "awkgram.y" /* yacc.c:1646 */
+#line 1133 "awkgram.y" /* yacc.c:1646 */
{
if ((yyvsp[-1]) == NULL)
(yyval) = list_create((yyvsp[0]));
else
(yyval) = list_prepend((yyvsp[-1]), (yyvsp[0]));
}
-#line 2952 "awkgram.c" /* yacc.c:1646 */
+#line 2951 "awkgram.c" /* yacc.c:1646 */
break;
case 70:
-#line 1141 "awkgram.y" /* yacc.c:1646 */
+#line 1140 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 2958 "awkgram.c" /* yacc.c:1646 */
+#line 2957 "awkgram.c" /* yacc.c:1646 */
break;
case 71:
-#line 1146 "awkgram.y" /* yacc.c:1646 */
+#line 1145 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *casestmt = (yyvsp[0]);
if ((yyvsp[0]) == NULL)
@@ -2970,11 +2969,11 @@ regular_print:
bcfree((yyvsp[-2]));
(yyval) = (yyvsp[-4]);
}
-#line 2974 "awkgram.c" /* yacc.c:1646 */
+#line 2973 "awkgram.c" /* yacc.c:1646 */
break;
case 72:
-#line 1158 "awkgram.y" /* yacc.c:1646 */
+#line 1157 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *casestmt = (yyvsp[0]);
if ((yyvsp[0]) == NULL)
@@ -2985,17 +2984,17 @@ regular_print:
(yyvsp[-3])->case_stmt = casestmt;
(yyval) = (yyvsp[-3]);
}
-#line 2989 "awkgram.c" /* yacc.c:1646 */
+#line 2988 "awkgram.c" /* yacc.c:1646 */
break;
case 73:
-#line 1172 "awkgram.y" /* yacc.c:1646 */
+#line 1171 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 2995 "awkgram.c" /* yacc.c:1646 */
+#line 2994 "awkgram.c" /* yacc.c:1646 */
break;
case 74:
-#line 1174 "awkgram.y" /* yacc.c:1646 */
+#line 1173 "awkgram.y" /* yacc.c:1646 */
{
NODE *n = (yyvsp[0])->memory;
(void) force_number(n);
@@ -3003,71 +3002,71 @@ regular_print:
bcfree((yyvsp[-1]));
(yyval) = (yyvsp[0]);
}
-#line 3007 "awkgram.c" /* yacc.c:1646 */
+#line 3006 "awkgram.c" /* yacc.c:1646 */
break;
case 75:
-#line 1182 "awkgram.y" /* yacc.c:1646 */
+#line 1181 "awkgram.y" /* yacc.c:1646 */
{
bcfree((yyvsp[-1]));
(yyval) = (yyvsp[0]);
}
-#line 3016 "awkgram.c" /* yacc.c:1646 */
+#line 3015 "awkgram.c" /* yacc.c:1646 */
break;
case 76:
-#line 1187 "awkgram.y" /* yacc.c:1646 */
+#line 1186 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3022 "awkgram.c" /* yacc.c:1646 */
+#line 3021 "awkgram.c" /* yacc.c:1646 */
break;
case 77:
-#line 1189 "awkgram.y" /* yacc.c:1646 */
+#line 1188 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[0])->opcode = Op_push_re;
(yyval) = (yyvsp[0]);
}
-#line 3031 "awkgram.c" /* yacc.c:1646 */
+#line 3030 "awkgram.c" /* yacc.c:1646 */
break;
case 78:
-#line 1197 "awkgram.y" /* yacc.c:1646 */
+#line 1196 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3037 "awkgram.c" /* yacc.c:1646 */
+#line 3036 "awkgram.c" /* yacc.c:1646 */
break;
case 79:
-#line 1199 "awkgram.y" /* yacc.c:1646 */
+#line 1198 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3043 "awkgram.c" /* yacc.c:1646 */
+#line 3042 "awkgram.c" /* yacc.c:1646 */
break;
case 81:
-#line 1209 "awkgram.y" /* yacc.c:1646 */
+#line 1208 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = (yyvsp[-1]);
}
-#line 3051 "awkgram.c" /* yacc.c:1646 */
+#line 3050 "awkgram.c" /* yacc.c:1646 */
break;
case 82:
-#line 1216 "awkgram.y" /* yacc.c:1646 */
+#line 1215 "awkgram.y" /* yacc.c:1646 */
{
in_print = false;
in_parens = 0;
(yyval) = NULL;
}
-#line 3061 "awkgram.c" /* yacc.c:1646 */
+#line 3060 "awkgram.c" /* yacc.c:1646 */
break;
case 83:
-#line 1221 "awkgram.y" /* yacc.c:1646 */
+#line 1220 "awkgram.y" /* yacc.c:1646 */
{ in_print = false; in_parens = 0; }
-#line 3067 "awkgram.c" /* yacc.c:1646 */
+#line 3066 "awkgram.c" /* yacc.c:1646 */
break;
case 84:
-#line 1222 "awkgram.y" /* yacc.c:1646 */
+#line 1221 "awkgram.y" /* yacc.c:1646 */
{
if ((yyvsp[-2])->redir_type == redirect_twoway
&& (yyvsp[0])->lasti->opcode == Op_K_getline_redir
@@ -3075,136 +3074,136 @@ regular_print:
yyerror(_("multistage two-way pipelines don't work"));
(yyval) = list_prepend((yyvsp[0]), (yyvsp[-2]));
}
-#line 3079 "awkgram.c" /* yacc.c:1646 */
+#line 3078 "awkgram.c" /* yacc.c:1646 */
break;
case 85:
-#line 1233 "awkgram.y" /* yacc.c:1646 */
+#line 1232 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = mk_condition((yyvsp[-3]), (yyvsp[-5]), (yyvsp[0]), NULL, NULL);
}
-#line 3087 "awkgram.c" /* yacc.c:1646 */
+#line 3086 "awkgram.c" /* yacc.c:1646 */
break;
case 86:
-#line 1238 "awkgram.y" /* yacc.c:1646 */
+#line 1237 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = mk_condition((yyvsp[-6]), (yyvsp[-8]), (yyvsp[-3]), (yyvsp[-2]), (yyvsp[0]));
}
-#line 3095 "awkgram.c" /* yacc.c:1646 */
+#line 3094 "awkgram.c" /* yacc.c:1646 */
break;
case 91:
-#line 1255 "awkgram.y" /* yacc.c:1646 */
+#line 1254 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3101 "awkgram.c" /* yacc.c:1646 */
+#line 3100 "awkgram.c" /* yacc.c:1646 */
break;
case 92:
-#line 1257 "awkgram.y" /* yacc.c:1646 */
+#line 1256 "awkgram.y" /* yacc.c:1646 */
{
bcfree((yyvsp[-1]));
(yyval) = (yyvsp[0]);
}
-#line 3110 "awkgram.c" /* yacc.c:1646 */
+#line 3109 "awkgram.c" /* yacc.c:1646 */
break;
case 93:
-#line 1265 "awkgram.y" /* yacc.c:1646 */
+#line 1264 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3116 "awkgram.c" /* yacc.c:1646 */
+#line 3115 "awkgram.c" /* yacc.c:1646 */
break;
case 94:
-#line 1267 "awkgram.y" /* yacc.c:1646 */
+#line 1266 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3122 "awkgram.c" /* yacc.c:1646 */
+#line 3121 "awkgram.c" /* yacc.c:1646 */
break;
case 95:
-#line 1272 "awkgram.y" /* yacc.c:1646 */
+#line 1271 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[0])->param_count = 0;
(yyval) = list_create((yyvsp[0]));
}
-#line 3131 "awkgram.c" /* yacc.c:1646 */
+#line 3130 "awkgram.c" /* yacc.c:1646 */
break;
case 96:
-#line 1277 "awkgram.y" /* yacc.c:1646 */
+#line 1276 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[0])->param_count = (yyvsp[-2])->lasti->param_count + 1;
(yyval) = list_append((yyvsp[-2]), (yyvsp[0]));
yyerrok;
}
-#line 3141 "awkgram.c" /* yacc.c:1646 */
+#line 3140 "awkgram.c" /* yacc.c:1646 */
break;
case 97:
-#line 1283 "awkgram.y" /* yacc.c:1646 */
+#line 1282 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3147 "awkgram.c" /* yacc.c:1646 */
+#line 3146 "awkgram.c" /* yacc.c:1646 */
break;
case 98:
-#line 1285 "awkgram.y" /* yacc.c:1646 */
+#line 1284 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[-1]); }
-#line 3153 "awkgram.c" /* yacc.c:1646 */
+#line 3152 "awkgram.c" /* yacc.c:1646 */
break;
case 99:
-#line 1287 "awkgram.y" /* yacc.c:1646 */
+#line 1286 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[-2]); }
-#line 3159 "awkgram.c" /* yacc.c:1646 */
+#line 3158 "awkgram.c" /* yacc.c:1646 */
break;
case 100:
-#line 1293 "awkgram.y" /* yacc.c:1646 */
+#line 1292 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3165 "awkgram.c" /* yacc.c:1646 */
+#line 3164 "awkgram.c" /* yacc.c:1646 */
break;
case 101:
-#line 1295 "awkgram.y" /* yacc.c:1646 */
+#line 1294 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3171 "awkgram.c" /* yacc.c:1646 */
+#line 3170 "awkgram.c" /* yacc.c:1646 */
break;
case 102:
-#line 1300 "awkgram.y" /* yacc.c:1646 */
+#line 1299 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3177 "awkgram.c" /* yacc.c:1646 */
+#line 3176 "awkgram.c" /* yacc.c:1646 */
break;
case 103:
-#line 1302 "awkgram.y" /* yacc.c:1646 */
+#line 1301 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3183 "awkgram.c" /* yacc.c:1646 */
+#line 3182 "awkgram.c" /* yacc.c:1646 */
break;
case 104:
-#line 1307 "awkgram.y" /* yacc.c:1646 */
+#line 1306 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_expression_list(NULL, (yyvsp[0])); }
-#line 3189 "awkgram.c" /* yacc.c:1646 */
+#line 3188 "awkgram.c" /* yacc.c:1646 */
break;
case 105:
-#line 1309 "awkgram.y" /* yacc.c:1646 */
+#line 1308 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0]));
yyerrok;
}
-#line 3198 "awkgram.c" /* yacc.c:1646 */
+#line 3197 "awkgram.c" /* yacc.c:1646 */
break;
case 106:
-#line 1314 "awkgram.y" /* yacc.c:1646 */
+#line 1313 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3204 "awkgram.c" /* yacc.c:1646 */
+#line 3203 "awkgram.c" /* yacc.c:1646 */
break;
case 107:
-#line 1316 "awkgram.y" /* yacc.c:1646 */
+#line 1315 "awkgram.y" /* yacc.c:1646 */
{
/*
* Returning the expression list instead of NULL lets
@@ -3212,52 +3211,52 @@ regular_print:
*/
(yyval) = (yyvsp[-1]);
}
-#line 3216 "awkgram.c" /* yacc.c:1646 */
+#line 3215 "awkgram.c" /* yacc.c:1646 */
break;
case 108:
-#line 1324 "awkgram.y" /* yacc.c:1646 */
+#line 1323 "awkgram.y" /* yacc.c:1646 */
{
/* Ditto */
(yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0]));
}
-#line 3225 "awkgram.c" /* yacc.c:1646 */
+#line 3224 "awkgram.c" /* yacc.c:1646 */
break;
case 109:
-#line 1329 "awkgram.y" /* yacc.c:1646 */
+#line 1328 "awkgram.y" /* yacc.c:1646 */
{
/* Ditto */
(yyval) = (yyvsp[-2]);
}
-#line 3234 "awkgram.c" /* yacc.c:1646 */
+#line 3233 "awkgram.c" /* yacc.c:1646 */
break;
case 110:
-#line 1338 "awkgram.y" /* yacc.c:1646 */
+#line 1337 "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 3245 "awkgram.c" /* yacc.c:1646 */
+#line 3244 "awkgram.c" /* yacc.c:1646 */
break;
case 111:
-#line 1345 "awkgram.y" /* yacc.c:1646 */
+#line 1344 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3251 "awkgram.c" /* yacc.c:1646 */
+#line 3250 "awkgram.c" /* yacc.c:1646 */
break;
case 112:
-#line 1347 "awkgram.y" /* yacc.c:1646 */
+#line 1346 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3257 "awkgram.c" /* yacc.c:1646 */
+#line 3256 "awkgram.c" /* yacc.c:1646 */
break;
case 113:
-#line 1349 "awkgram.y" /* yacc.c:1646 */
+#line 1348 "awkgram.y" /* yacc.c:1646 */
{
if ((yyvsp[-2])->lasti->opcode == Op_match_rec)
warning_ln((yyvsp[-1])->source_line,
@@ -3273,11 +3272,11 @@ regular_print:
(yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1]));
}
}
-#line 3277 "awkgram.c" /* yacc.c:1646 */
+#line 3276 "awkgram.c" /* yacc.c:1646 */
break;
case 114:
-#line 1365 "awkgram.y" /* yacc.c:1646 */
+#line 1364 "awkgram.y" /* yacc.c:1646 */
{
if (do_lint_old)
warning_ln((yyvsp[-1])->source_line,
@@ -3287,91 +3286,91 @@ regular_print:
(yyvsp[-1])->expr_count = 1;
(yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1]));
}
-#line 3291 "awkgram.c" /* yacc.c:1646 */
+#line 3290 "awkgram.c" /* yacc.c:1646 */
break;
case 115:
-#line 1375 "awkgram.y" /* yacc.c:1646 */
+#line 1374 "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 3302 "awkgram.c" /* yacc.c:1646 */
+#line 3301 "awkgram.c" /* yacc.c:1646 */
break;
case 116:
-#line 1382 "awkgram.y" /* yacc.c:1646 */
+#line 1381 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_condition((yyvsp[-4]), (yyvsp[-3]), (yyvsp[-2]), (yyvsp[-1]), (yyvsp[0])); }
-#line 3308 "awkgram.c" /* yacc.c:1646 */
+#line 3307 "awkgram.c" /* yacc.c:1646 */
break;
case 117:
-#line 1384 "awkgram.y" /* yacc.c:1646 */
+#line 1383 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3314 "awkgram.c" /* yacc.c:1646 */
+#line 3313 "awkgram.c" /* yacc.c:1646 */
break;
case 118:
-#line 1389 "awkgram.y" /* yacc.c:1646 */
+#line 1388 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3320 "awkgram.c" /* yacc.c:1646 */
+#line 3319 "awkgram.c" /* yacc.c:1646 */
break;
case 119:
-#line 1391 "awkgram.y" /* yacc.c:1646 */
+#line 1390 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3326 "awkgram.c" /* yacc.c:1646 */
+#line 3325 "awkgram.c" /* yacc.c:1646 */
break;
case 120:
-#line 1393 "awkgram.y" /* yacc.c:1646 */
+#line 1392 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[0])->opcode = Op_assign_quotient;
(yyval) = (yyvsp[0]);
}
-#line 3335 "awkgram.c" /* yacc.c:1646 */
+#line 3334 "awkgram.c" /* yacc.c:1646 */
break;
case 121:
-#line 1401 "awkgram.y" /* yacc.c:1646 */
+#line 1400 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3341 "awkgram.c" /* yacc.c:1646 */
+#line 3340 "awkgram.c" /* yacc.c:1646 */
break;
case 122:
-#line 1403 "awkgram.y" /* yacc.c:1646 */
+#line 1402 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3347 "awkgram.c" /* yacc.c:1646 */
+#line 3346 "awkgram.c" /* yacc.c:1646 */
break;
case 123:
-#line 1408 "awkgram.y" /* yacc.c:1646 */
+#line 1407 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3353 "awkgram.c" /* yacc.c:1646 */
+#line 3352 "awkgram.c" /* yacc.c:1646 */
break;
case 124:
-#line 1410 "awkgram.y" /* yacc.c:1646 */
+#line 1409 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3359 "awkgram.c" /* yacc.c:1646 */
+#line 3358 "awkgram.c" /* yacc.c:1646 */
break;
case 125:
-#line 1415 "awkgram.y" /* yacc.c:1646 */
+#line 1414 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3365 "awkgram.c" /* yacc.c:1646 */
+#line 3364 "awkgram.c" /* yacc.c:1646 */
break;
case 126:
-#line 1417 "awkgram.y" /* yacc.c:1646 */
+#line 1416 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3371 "awkgram.c" /* yacc.c:1646 */
+#line 3370 "awkgram.c" /* yacc.c:1646 */
break;
case 127:
-#line 1419 "awkgram.y" /* yacc.c:1646 */
+#line 1418 "awkgram.y" /* yacc.c:1646 */
{
int count = 2;
bool is_simple_var = false;
@@ -3418,47 +3417,47 @@ regular_print:
max_args = count;
}
}
-#line 3422 "awkgram.c" /* yacc.c:1646 */
+#line 3421 "awkgram.c" /* yacc.c:1646 */
break;
case 129:
-#line 1471 "awkgram.y" /* yacc.c:1646 */
+#line 1470 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3428 "awkgram.c" /* yacc.c:1646 */
+#line 3427 "awkgram.c" /* yacc.c:1646 */
break;
case 130:
-#line 1473 "awkgram.y" /* yacc.c:1646 */
+#line 1472 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3434 "awkgram.c" /* yacc.c:1646 */
+#line 3433 "awkgram.c" /* yacc.c:1646 */
break;
case 131:
-#line 1475 "awkgram.y" /* yacc.c:1646 */
+#line 1474 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3440 "awkgram.c" /* yacc.c:1646 */
+#line 3439 "awkgram.c" /* yacc.c:1646 */
break;
case 132:
-#line 1477 "awkgram.y" /* yacc.c:1646 */
+#line 1476 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3446 "awkgram.c" /* yacc.c:1646 */
+#line 3445 "awkgram.c" /* yacc.c:1646 */
break;
case 133:
-#line 1479 "awkgram.y" /* yacc.c:1646 */
+#line 1478 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3452 "awkgram.c" /* yacc.c:1646 */
+#line 3451 "awkgram.c" /* yacc.c:1646 */
break;
case 134:
-#line 1481 "awkgram.y" /* yacc.c:1646 */
+#line 1480 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3458 "awkgram.c" /* yacc.c:1646 */
+#line 3457 "awkgram.c" /* yacc.c:1646 */
break;
case 135:
-#line 1483 "awkgram.y" /* yacc.c:1646 */
+#line 1482 "awkgram.y" /* yacc.c:1646 */
{
/*
* In BEGINFILE/ENDFILE, allow `getline [var] < file'
@@ -3472,29 +3471,29 @@ regular_print:
_("non-redirected `getline' undefined inside END action"));
(yyval) = mk_getline((yyvsp[-2]), (yyvsp[-1]), (yyvsp[0]), redirect_input);
}
-#line 3476 "awkgram.c" /* yacc.c:1646 */
+#line 3475 "awkgram.c" /* yacc.c:1646 */
break;
case 136:
-#line 1497 "awkgram.y" /* yacc.c:1646 */
+#line 1496 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[0])->opcode = Op_postincrement;
(yyval) = mk_assignment((yyvsp[-1]), NULL, (yyvsp[0]));
}
-#line 3485 "awkgram.c" /* yacc.c:1646 */
+#line 3484 "awkgram.c" /* yacc.c:1646 */
break;
case 137:
-#line 1502 "awkgram.y" /* yacc.c:1646 */
+#line 1501 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[0])->opcode = Op_postdecrement;
(yyval) = mk_assignment((yyvsp[-1]), NULL, (yyvsp[0]));
}
-#line 3494 "awkgram.c" /* yacc.c:1646 */
+#line 3493 "awkgram.c" /* yacc.c:1646 */
break;
case 138:
-#line 1507 "awkgram.y" /* yacc.c:1646 */
+#line 1506 "awkgram.y" /* yacc.c:1646 */
{
if (do_lint_old) {
warning_ln((yyvsp[-1])->source_line,
@@ -3514,64 +3513,64 @@ regular_print:
(yyval) = list_append(list_merge(t, (yyvsp[0])), (yyvsp[-1]));
}
}
-#line 3518 "awkgram.c" /* yacc.c:1646 */
+#line 3517 "awkgram.c" /* yacc.c:1646 */
break;
case 139:
-#line 1532 "awkgram.y" /* yacc.c:1646 */
+#line 1531 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = mk_getline((yyvsp[-1]), (yyvsp[0]), (yyvsp[-3]), (yyvsp[-2])->redir_type);
bcfree((yyvsp[-2]));
}
-#line 3527 "awkgram.c" /* yacc.c:1646 */
+#line 3526 "awkgram.c" /* yacc.c:1646 */
break;
case 140:
-#line 1538 "awkgram.y" /* yacc.c:1646 */
+#line 1537 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3533 "awkgram.c" /* yacc.c:1646 */
+#line 3532 "awkgram.c" /* yacc.c:1646 */
break;
case 141:
-#line 1540 "awkgram.y" /* yacc.c:1646 */
+#line 1539 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3539 "awkgram.c" /* yacc.c:1646 */
+#line 3538 "awkgram.c" /* yacc.c:1646 */
break;
case 142:
-#line 1542 "awkgram.y" /* yacc.c:1646 */
+#line 1541 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3545 "awkgram.c" /* yacc.c:1646 */
+#line 3544 "awkgram.c" /* yacc.c:1646 */
break;
case 143:
-#line 1544 "awkgram.y" /* yacc.c:1646 */
+#line 1543 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3551 "awkgram.c" /* yacc.c:1646 */
+#line 3550 "awkgram.c" /* yacc.c:1646 */
break;
case 144:
-#line 1546 "awkgram.y" /* yacc.c:1646 */
+#line 1545 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3557 "awkgram.c" /* yacc.c:1646 */
+#line 3556 "awkgram.c" /* yacc.c:1646 */
break;
case 145:
-#line 1548 "awkgram.y" /* yacc.c:1646 */
+#line 1547 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3563 "awkgram.c" /* yacc.c:1646 */
+#line 3562 "awkgram.c" /* yacc.c:1646 */
break;
case 146:
-#line 1553 "awkgram.y" /* yacc.c:1646 */
+#line 1552 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = list_create((yyvsp[0]));
}
-#line 3571 "awkgram.c" /* yacc.c:1646 */
+#line 3570 "awkgram.c" /* yacc.c:1646 */
break;
case 147:
-#line 1557 "awkgram.y" /* yacc.c:1646 */
+#line 1556 "awkgram.y" /* yacc.c:1646 */
{
if ((yyvsp[0])->opcode == Op_match_rec) {
(yyvsp[0])->opcode = Op_nomatch;
@@ -3603,37 +3602,37 @@ regular_print:
}
}
}
-#line 3607 "awkgram.c" /* yacc.c:1646 */
+#line 3606 "awkgram.c" /* yacc.c:1646 */
break;
case 148:
-#line 1589 "awkgram.y" /* yacc.c:1646 */
+#line 1588 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[-1]); }
-#line 3613 "awkgram.c" /* yacc.c:1646 */
+#line 3612 "awkgram.c" /* yacc.c:1646 */
break;
case 149:
-#line 1591 "awkgram.y" /* yacc.c:1646 */
+#line 1590 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = snode((yyvsp[-1]), (yyvsp[-3]));
if ((yyval) == NULL)
YYABORT;
}
-#line 3623 "awkgram.c" /* yacc.c:1646 */
+#line 3622 "awkgram.c" /* yacc.c:1646 */
break;
case 150:
-#line 1597 "awkgram.y" /* yacc.c:1646 */
+#line 1596 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = snode((yyvsp[-1]), (yyvsp[-3]));
if ((yyval) == NULL)
YYABORT;
}
-#line 3633 "awkgram.c" /* yacc.c:1646 */
+#line 3632 "awkgram.c" /* yacc.c:1646 */
break;
case 151:
-#line 1603 "awkgram.y" /* yacc.c:1646 */
+#line 1602 "awkgram.y" /* yacc.c:1646 */
{
static bool warned = false;
@@ -3646,45 +3645,45 @@ regular_print:
if ((yyval) == NULL)
YYABORT;
}
-#line 3650 "awkgram.c" /* yacc.c:1646 */
+#line 3649 "awkgram.c" /* yacc.c:1646 */
break;
case 154:
-#line 1618 "awkgram.y" /* yacc.c:1646 */
+#line 1617 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[-1])->opcode = Op_preincrement;
(yyval) = mk_assignment((yyvsp[0]), NULL, (yyvsp[-1]));
}
-#line 3659 "awkgram.c" /* yacc.c:1646 */
+#line 3658 "awkgram.c" /* yacc.c:1646 */
break;
case 155:
-#line 1623 "awkgram.y" /* yacc.c:1646 */
+#line 1622 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[-1])->opcode = Op_predecrement;
(yyval) = mk_assignment((yyvsp[0]), NULL, (yyvsp[-1]));
}
-#line 3668 "awkgram.c" /* yacc.c:1646 */
+#line 3667 "awkgram.c" /* yacc.c:1646 */
break;
case 156:
-#line 1628 "awkgram.y" /* yacc.c:1646 */
+#line 1627 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = list_create((yyvsp[0]));
}
-#line 3676 "awkgram.c" /* yacc.c:1646 */
+#line 3675 "awkgram.c" /* yacc.c:1646 */
break;
case 157:
-#line 1632 "awkgram.y" /* yacc.c:1646 */
+#line 1631 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = list_create((yyvsp[0]));
}
-#line 3684 "awkgram.c" /* yacc.c:1646 */
+#line 3683 "awkgram.c" /* yacc.c:1646 */
break;
case 158:
-#line 1636 "awkgram.y" /* yacc.c:1646 */
+#line 1635 "awkgram.y" /* yacc.c:1646 */
{
if ((yyvsp[0])->lasti->opcode == Op_push_i
&& ((yyvsp[0])->lasti->memory->flags & (STRCUR|STRING)) == 0
@@ -3699,11 +3698,11 @@ regular_print:
(yyval) = list_append((yyvsp[0]), (yyvsp[-1]));
}
}
-#line 3703 "awkgram.c" /* yacc.c:1646 */
+#line 3702 "awkgram.c" /* yacc.c:1646 */
break;
case 159:
-#line 1651 "awkgram.y" /* yacc.c:1646 */
+#line 1650 "awkgram.y" /* yacc.c:1646 */
{
/*
* was: $$ = $2
@@ -3713,20 +3712,20 @@ regular_print:
(yyvsp[-1])->memory = make_number(0.0);
(yyval) = list_append((yyvsp[0]), (yyvsp[-1]));
}
-#line 3717 "awkgram.c" /* yacc.c:1646 */
+#line 3716 "awkgram.c" /* yacc.c:1646 */
break;
case 160:
-#line 1664 "awkgram.y" /* yacc.c:1646 */
+#line 1663 "awkgram.y" /* yacc.c:1646 */
{
func_use((yyvsp[0])->lasti->func_name, FUNC_USE);
(yyval) = (yyvsp[0]);
}
-#line 3726 "awkgram.c" /* yacc.c:1646 */
+#line 3725 "awkgram.c" /* yacc.c:1646 */
break;
case 161:
-#line 1669 "awkgram.y" /* yacc.c:1646 */
+#line 1668 "awkgram.y" /* yacc.c:1646 */
{
/* indirect function call */
INSTRUCTION *f, *t;
@@ -3760,11 +3759,11 @@ regular_print:
(yyval) = list_prepend((yyvsp[0]), t);
at_seen = false;
}
-#line 3764 "awkgram.c" /* yacc.c:1646 */
+#line 3763 "awkgram.c" /* yacc.c:1646 */
break;
case 162:
-#line 1706 "awkgram.y" /* yacc.c:1646 */
+#line 1705 "awkgram.y" /* yacc.c:1646 */
{
NODE *n;
@@ -3789,49 +3788,49 @@ regular_print:
(yyval) = list_append(t, (yyvsp[-3]));
}
}
-#line 3793 "awkgram.c" /* yacc.c:1646 */
+#line 3792 "awkgram.c" /* yacc.c:1646 */
break;
case 163:
-#line 1734 "awkgram.y" /* yacc.c:1646 */
+#line 1733 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3799 "awkgram.c" /* yacc.c:1646 */
+#line 3798 "awkgram.c" /* yacc.c:1646 */
break;
case 164:
-#line 1736 "awkgram.y" /* yacc.c:1646 */
+#line 1735 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3805 "awkgram.c" /* yacc.c:1646 */
+#line 3804 "awkgram.c" /* yacc.c:1646 */
break;
case 165:
-#line 1741 "awkgram.y" /* yacc.c:1646 */
+#line 1740 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3811 "awkgram.c" /* yacc.c:1646 */
+#line 3810 "awkgram.c" /* yacc.c:1646 */
break;
case 166:
-#line 1743 "awkgram.y" /* yacc.c:1646 */
+#line 1742 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[-1]); }
-#line 3817 "awkgram.c" /* yacc.c:1646 */
+#line 3816 "awkgram.c" /* yacc.c:1646 */
break;
case 167:
-#line 1748 "awkgram.y" /* yacc.c:1646 */
+#line 1747 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3823 "awkgram.c" /* yacc.c:1646 */
+#line 3822 "awkgram.c" /* yacc.c:1646 */
break;
case 168:
-#line 1750 "awkgram.y" /* yacc.c:1646 */
+#line 1749 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = list_merge((yyvsp[-1]), (yyvsp[0]));
}
-#line 3831 "awkgram.c" /* yacc.c:1646 */
+#line 3830 "awkgram.c" /* yacc.c:1646 */
break;
case 169:
-#line 1757 "awkgram.y" /* yacc.c:1646 */
+#line 1756 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *ip = (yyvsp[0])->lasti;
int count = ip->sub_count; /* # of SUBSEP-seperated expressions */
@@ -3845,11 +3844,11 @@ regular_print:
sub_counter++; /* count # of dimensions */
(yyval) = (yyvsp[0]);
}
-#line 3849 "awkgram.c" /* yacc.c:1646 */
+#line 3848 "awkgram.c" /* yacc.c:1646 */
break;
case 170:
-#line 1774 "awkgram.y" /* yacc.c:1646 */
+#line 1773 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *t = (yyvsp[-1]);
if ((yyvsp[-1]) == NULL) {
@@ -3863,31 +3862,31 @@ regular_print:
(yyvsp[0])->sub_count = count_expressions(&t, false);
(yyval) = list_append(t, (yyvsp[0]));
}
-#line 3867 "awkgram.c" /* yacc.c:1646 */
+#line 3866 "awkgram.c" /* yacc.c:1646 */
break;
case 171:
-#line 1791 "awkgram.y" /* yacc.c:1646 */
+#line 1790 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3873 "awkgram.c" /* yacc.c:1646 */
+#line 3872 "awkgram.c" /* yacc.c:1646 */
break;
case 172:
-#line 1793 "awkgram.y" /* yacc.c:1646 */
+#line 1792 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = list_merge((yyvsp[-1]), (yyvsp[0]));
}
-#line 3881 "awkgram.c" /* yacc.c:1646 */
+#line 3880 "awkgram.c" /* yacc.c:1646 */
break;
case 173:
-#line 1800 "awkgram.y" /* yacc.c:1646 */
+#line 1799 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[-1]); }
-#line 3887 "awkgram.c" /* yacc.c:1646 */
+#line 3886 "awkgram.c" /* yacc.c:1646 */
break;
case 174:
-#line 1805 "awkgram.y" /* yacc.c:1646 */
+#line 1804 "awkgram.y" /* yacc.c:1646 */
{
char *var_name = (yyvsp[0])->lextok;
@@ -3895,22 +3894,22 @@ regular_print:
(yyvsp[0])->memory = variable((yyvsp[0])->source_line, var_name, Node_var_new);
(yyval) = list_create((yyvsp[0]));
}
-#line 3899 "awkgram.c" /* yacc.c:1646 */
+#line 3898 "awkgram.c" /* yacc.c:1646 */
break;
case 175:
-#line 1813 "awkgram.y" /* yacc.c:1646 */
+#line 1812 "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 3910 "awkgram.c" /* yacc.c:1646 */
+#line 3909 "awkgram.c" /* yacc.c:1646 */
break;
case 176:
-#line 1823 "awkgram.y" /* yacc.c:1646 */
+#line 1822 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *ip = (yyvsp[0])->nexti;
if (ip->opcode == Op_push
@@ -3922,73 +3921,73 @@ regular_print:
} else
(yyval) = (yyvsp[0]);
}
-#line 3926 "awkgram.c" /* yacc.c:1646 */
+#line 3925 "awkgram.c" /* yacc.c:1646 */
break;
case 177:
-#line 1835 "awkgram.y" /* yacc.c:1646 */
+#line 1834 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = list_append((yyvsp[-1]), (yyvsp[-2]));
if ((yyvsp[0]) != NULL)
mk_assignment((yyvsp[-1]), NULL, (yyvsp[0]));
}
-#line 3936 "awkgram.c" /* yacc.c:1646 */
+#line 3935 "awkgram.c" /* yacc.c:1646 */
break;
case 178:
-#line 1844 "awkgram.y" /* yacc.c:1646 */
+#line 1843 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[0])->opcode = Op_postincrement;
}
-#line 3944 "awkgram.c" /* yacc.c:1646 */
+#line 3943 "awkgram.c" /* yacc.c:1646 */
break;
case 179:
-#line 1848 "awkgram.y" /* yacc.c:1646 */
+#line 1847 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[0])->opcode = Op_postdecrement;
}
-#line 3952 "awkgram.c" /* yacc.c:1646 */
+#line 3951 "awkgram.c" /* yacc.c:1646 */
break;
case 180:
-#line 1851 "awkgram.y" /* yacc.c:1646 */
+#line 1850 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3958 "awkgram.c" /* yacc.c:1646 */
+#line 3957 "awkgram.c" /* yacc.c:1646 */
break;
case 182:
-#line 1859 "awkgram.y" /* yacc.c:1646 */
+#line 1858 "awkgram.y" /* yacc.c:1646 */
{ yyerrok; }
-#line 3964 "awkgram.c" /* yacc.c:1646 */
+#line 3963 "awkgram.c" /* yacc.c:1646 */
break;
case 183:
-#line 1863 "awkgram.y" /* yacc.c:1646 */
+#line 1862 "awkgram.y" /* yacc.c:1646 */
{ yyerrok; }
-#line 3970 "awkgram.c" /* yacc.c:1646 */
+#line 3969 "awkgram.c" /* yacc.c:1646 */
break;
case 186:
-#line 1872 "awkgram.y" /* yacc.c:1646 */
+#line 1871 "awkgram.y" /* yacc.c:1646 */
{ yyerrok; }
-#line 3976 "awkgram.c" /* yacc.c:1646 */
+#line 3975 "awkgram.c" /* yacc.c:1646 */
break;
case 187:
-#line 1876 "awkgram.y" /* yacc.c:1646 */
+#line 1875 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); yyerrok; }
-#line 3982 "awkgram.c" /* yacc.c:1646 */
+#line 3981 "awkgram.c" /* yacc.c:1646 */
break;
case 188:
-#line 1880 "awkgram.y" /* yacc.c:1646 */
+#line 1879 "awkgram.y" /* yacc.c:1646 */
{ yyerrok; }
-#line 3988 "awkgram.c" /* yacc.c:1646 */
+#line 3987 "awkgram.c" /* yacc.c:1646 */
break;
-#line 3992 "awkgram.c" /* yacc.c:1646 */
+#line 3991 "awkgram.c" /* yacc.c:1646 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@@ -4216,7 +4215,7 @@ yyreturn:
#endif
return yyresult;
}
-#line 1882 "awkgram.y" /* yacc.c:1906 */
+#line 1881 "awkgram.y" /* yacc.c:1906 */
struct token {
@@ -7050,7 +7049,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;
@@ -8206,13 +8205,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;
}
@@ -8225,7 +8237,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);
}
diff --git a/awkgram.y b/awkgram.y
index 95111a41..4092a177 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -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);
@@ -4712,7 +4711,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;
@@ -5868,13 +5867,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;
}
@@ -5887,7 +5899,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);
}
diff --git a/builtin.c b/builtin.c
index 37f5ffc7..99293b9a 100644
--- a/builtin.c
+++ b/builtin.c
@@ -3072,6 +3072,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 08c91bd7..e41bf158 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,6 +1,8 @@
2015-03-31 Arnold D. Robbins <arnold@skeeve.com>
- * gawktexi.in: Minor edits.
+ * gawktexi.in: Update discussion of calling built-in functions
+ indirectly. Small additional fix relating to rand(). Thanks
+ to Antonio Colombo.
2015-03-27 Arnold D. Robbins <arnold@skeeve.com>
diff --git a/doc/gawk.info b/doc/gawk.info
index a208f834..24a4a638 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -12075,9 +12075,9 @@ brackets ([ ]):
return int(n * rand())
}
- The multiplication produces a random number greater than zero and
- less than `n'. Using `int()', this result is made into an integer
- between zero and `n' - 1, inclusive.
+ The multiplication produces a random number greater than or equal
+ to zero and less than `n'. Using `int()', this result is made into
+ an integer between zero and `n' - 1, inclusive.
The following example uses a similar function to produce random
integers between one and N. This program prints a new random
@@ -14440,9 +14440,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:
@@ -35118,333 +35126,333 @@ Node: Functions504950
Node: Built-in505989
Node: Calling Built-in507067
Node: Numeric Functions509062
-Ref: Numeric Functions-Footnote-1513880
-Ref: Numeric Functions-Footnote-2514237
-Ref: Numeric Functions-Footnote-3514285
-Node: String Functions514557
-Ref: String Functions-Footnote-1538058
-Ref: String Functions-Footnote-2538187
-Ref: String Functions-Footnote-3538435
-Node: Gory Details538522
-Ref: table-sub-escapes540303
-Ref: table-sub-proposed541818
-Ref: table-posix-sub543180
-Ref: table-gensub-escapes544717
-Ref: Gory Details-Footnote-1545550
-Node: I/O Functions545701
-Ref: I/O Functions-Footnote-1552937
-Node: Time Functions553084
-Ref: Time Functions-Footnote-1563593
-Ref: Time Functions-Footnote-2563661
-Ref: Time Functions-Footnote-3563819
-Ref: Time Functions-Footnote-4563930
-Ref: Time Functions-Footnote-5564042
-Ref: Time Functions-Footnote-6564269
-Node: Bitwise Functions564535
-Ref: table-bitwise-ops565097
-Ref: Bitwise Functions-Footnote-1569425
-Node: Type Functions569597
-Node: I18N Functions570749
-Node: User-defined572396
-Node: Definition Syntax573201
-Ref: Definition Syntax-Footnote-1578860
-Node: Function Example578931
-Ref: Function Example-Footnote-1581852
-Node: Function Caveats581874
-Node: Calling A Function582392
-Node: Variable Scope583350
-Node: Pass By Value/Reference586343
-Node: Return Statement589840
-Node: Dynamic Typing592819
-Node: Indirect Calls593748
-Ref: Indirect Calls-Footnote-1603613
-Node: Functions Summary603741
-Node: Library Functions606443
-Ref: Library Functions-Footnote-1610051
-Ref: Library Functions-Footnote-2610194
-Node: Library Names610365
-Ref: Library Names-Footnote-1613823
-Ref: Library Names-Footnote-2614046
-Node: General Functions614132
-Node: Strtonum Function615235
-Node: Assert Function618257
-Node: Round Function621581
-Node: Cliff Random Function623122
-Node: Ordinal Functions624138
-Ref: Ordinal Functions-Footnote-1627201
-Ref: Ordinal Functions-Footnote-2627453
-Node: Join Function627664
-Ref: Join Function-Footnote-1629434
-Node: Getlocaltime Function629634
-Node: Readfile Function633378
-Node: Shell Quoting635350
-Node: Data File Management636751
-Node: Filetrans Function637383
-Node: Rewind Function641479
-Node: File Checking642865
-Ref: File Checking-Footnote-1644198
-Node: Empty Files644399
-Node: Ignoring Assigns646378
-Node: Getopt Function647928
-Ref: Getopt Function-Footnote-1659392
-Node: Passwd Functions659592
-Ref: Passwd Functions-Footnote-1668432
-Node: Group Functions668520
-Ref: Group Functions-Footnote-1676417
-Node: Walking Arrays676622
-Node: Library Functions Summary679628
-Node: Library Exercises681030
-Node: Sample Programs682310
-Node: Running Examples683080
-Node: Clones683808
-Node: Cut Program685032
-Node: Egrep Program694752
-Ref: Egrep Program-Footnote-1702255
-Node: Id Program702365
-Node: Split Program706041
-Ref: Split Program-Footnote-1709495
-Node: Tee Program709623
-Node: Uniq Program712412
-Node: Wc Program719831
-Ref: Wc Program-Footnote-1724081
-Node: Miscellaneous Programs724175
-Node: Dupword Program725388
-Node: Alarm Program727419
-Node: Translate Program732224
-Ref: Translate Program-Footnote-1736787
-Node: Labels Program737057
-Ref: Labels Program-Footnote-1740408
-Node: Word Sorting740492
-Node: History Sorting744562
-Node: Extract Program746397
-Node: Simple Sed753921
-Node: Igawk Program756991
-Ref: Igawk Program-Footnote-1771317
-Ref: Igawk Program-Footnote-2771518
-Ref: Igawk Program-Footnote-3771640
-Node: Anagram Program771755
-Node: Signature Program774816
-Node: Programs Summary776063
-Node: Programs Exercises777284
-Ref: Programs Exercises-Footnote-1781415
-Node: Advanced Features781506
-Node: Nondecimal Data783488
-Node: Array Sorting785078
-Node: Controlling Array Traversal785778
-Ref: Controlling Array Traversal-Footnote-1794144
-Node: Array Sorting Functions794262
-Ref: Array Sorting Functions-Footnote-1798148
-Node: Two-way I/O798344
-Ref: Two-way I/O-Footnote-1803289
-Ref: Two-way I/O-Footnote-2803475
-Node: TCP/IP Networking803557
-Node: Profiling806429
-Node: Advanced Features Summary814700
-Node: Internationalization816633
-Node: I18N and L10N818113
-Node: Explaining gettext818799
-Ref: Explaining gettext-Footnote-1823824
-Ref: Explaining gettext-Footnote-2824008
-Node: Programmer i18n824173
-Ref: Programmer i18n-Footnote-1829049
-Node: Translator i18n829098
-Node: String Extraction829892
-Ref: String Extraction-Footnote-1831023
-Node: Printf Ordering831109
-Ref: Printf Ordering-Footnote-1833895
-Node: I18N Portability833959
-Ref: I18N Portability-Footnote-1836415
-Node: I18N Example836478
-Ref: I18N Example-Footnote-1839281
-Node: Gawk I18N839353
-Node: I18N Summary839997
-Node: Debugger841337
-Node: Debugging842359
-Node: Debugging Concepts842800
-Node: Debugging Terms844610
-Node: Awk Debugging847182
-Node: Sample Debugging Session848088
-Node: Debugger Invocation848622
-Node: Finding The Bug850007
-Node: List of Debugger Commands856486
-Node: Breakpoint Control857818
-Node: Debugger Execution Control861495
-Node: Viewing And Changing Data864854
-Node: Execution Stack868230
-Node: Debugger Info869865
-Node: Miscellaneous Debugger Commands873910
-Node: Readline Support878911
-Node: Limitations879805
-Node: Debugging Summary881920
-Node: Arbitrary Precision Arithmetic883094
-Node: Computer Arithmetic884510
-Ref: table-numeric-ranges888087
-Ref: Computer Arithmetic-Footnote-1888611
-Node: Math Definitions888668
-Ref: table-ieee-formats891963
-Ref: Math Definitions-Footnote-1892567
-Node: MPFR features892672
-Node: FP Math Caution894343
-Ref: FP Math Caution-Footnote-1895393
-Node: Inexactness of computations895762
-Node: Inexact representation896721
-Node: Comparing FP Values898079
-Node: Errors accumulate899161
-Node: Getting Accuracy900593
-Node: Try To Round903297
-Node: Setting precision904196
-Ref: table-predefined-precision-strings904880
-Node: Setting the rounding mode906709
-Ref: table-gawk-rounding-modes907073
-Ref: Setting the rounding mode-Footnote-1910525
-Node: Arbitrary Precision Integers910704
-Ref: Arbitrary Precision Integers-Footnote-1915602
-Node: POSIX Floating Point Problems915751
-Ref: POSIX Floating Point Problems-Footnote-1919630
-Node: Floating point summary919668
-Node: Dynamic Extensions921855
-Node: Extension Intro923407
-Node: Plugin License924672
-Node: Extension Mechanism Outline925469
-Ref: figure-load-extension925897
-Ref: figure-register-new-function927377
-Ref: figure-call-new-function928381
-Node: Extension API Description930368
-Node: Extension API Functions Introduction931902
-Node: General Data Types936771
-Ref: General Data Types-Footnote-1942671
-Node: Memory Allocation Functions942970
-Ref: Memory Allocation Functions-Footnote-1945809
-Node: Constructor Functions945908
-Node: Registration Functions947647
-Node: Extension Functions948332
-Node: Exit Callback Functions950629
-Node: Extension Version String951877
-Node: Input Parsers952540
-Node: Output Wrappers962415
-Node: Two-way processors966928
-Node: Printing Messages969191
-Ref: Printing Messages-Footnote-1970267
-Node: Updating `ERRNO'970419
-Node: Requesting Values971159
-Ref: table-value-types-returned971886
-Node: Accessing Parameters972843
-Node: Symbol Table Access974077
-Node: Symbol table by name974591
-Node: Symbol table by cookie976611
-Ref: Symbol table by cookie-Footnote-1980756
-Node: Cached values980819
-Ref: Cached values-Footnote-1984315
-Node: Array Manipulation984406
-Ref: Array Manipulation-Footnote-1985496
-Node: Array Data Types985533
-Ref: Array Data Types-Footnote-1988188
-Node: Array Functions988280
-Node: Flattening Arrays992139
-Node: Creating Arrays999041
-Node: Redirection API1003812
-Node: Extension API Variables1006637
-Node: Extension Versioning1007270
-Node: Extension API Informational Variables1009161
-Node: Extension API Boilerplate1010226
-Node: Finding Extensions1014035
-Node: Extension Example1014595
-Node: Internal File Description1015367
-Node: Internal File Ops1019434
-Ref: Internal File Ops-Footnote-11031185
-Node: Using Internal File Ops1031325
-Ref: Using Internal File Ops-Footnote-11033708
-Node: Extension Samples1033981
-Node: Extension Sample File Functions1035509
-Node: Extension Sample Fnmatch1043190
-Node: Extension Sample Fork1044678
-Node: Extension Sample Inplace1045893
-Node: Extension Sample Ord1047979
-Node: Extension Sample Readdir1048815
-Ref: table-readdir-file-types1049692
-Node: Extension Sample Revout1050503
-Node: Extension Sample Rev2way1051092
-Node: Extension Sample Read write array1051832
-Node: Extension Sample Readfile1053772
-Node: Extension Sample Time1054867
-Node: Extension Sample API Tests1056215
-Node: gawkextlib1056706
-Node: Extension summary1059407
-Node: Extension Exercises1063096
-Node: Language History1064592
-Node: V7/SVR3.11066248
-Node: SVR41068401
-Node: POSIX1069835
-Node: BTL1071216
-Node: POSIX/GNU1071947
-Node: Feature History1077783
-Node: Common Extensions1091577
-Node: Ranges and Locales1092949
-Ref: Ranges and Locales-Footnote-11097568
-Ref: Ranges and Locales-Footnote-21097595
-Ref: Ranges and Locales-Footnote-31097830
-Node: Contributors1098051
-Node: History summary1103591
-Node: Installation1104970
-Node: Gawk Distribution1105916
-Node: Getting1106400
-Node: Extracting1107223
-Node: Distribution contents1108860
-Node: Unix Installation1114962
-Node: Quick Installation1115645
-Node: Shell Startup Files1118056
-Node: Additional Configuration Options1119135
-Node: Configuration Philosophy1120939
-Node: Non-Unix Installation1123308
-Node: PC Installation1123766
-Node: PC Binary Installation1125086
-Node: PC Compiling1126934
-Ref: PC Compiling-Footnote-11129955
-Node: PC Testing1130064
-Node: PC Using1131240
-Node: Cygwin1135355
-Node: MSYS1136125
-Node: VMS Installation1136626
-Node: VMS Compilation1137418
-Ref: VMS Compilation-Footnote-11138647
-Node: VMS Dynamic Extensions1138705
-Node: VMS Installation Details1140389
-Node: VMS Running1142640
-Node: VMS GNV1145480
-Node: VMS Old Gawk1146215
-Node: Bugs1146685
-Node: Other Versions1150574
-Node: Installation summary1157008
-Node: Notes1158067
-Node: Compatibility Mode1158932
-Node: Additions1159714
-Node: Accessing The Source1160639
-Node: Adding Code1162074
-Node: New Ports1168231
-Node: Derived Files1172713
-Ref: Derived Files-Footnote-11178188
-Ref: Derived Files-Footnote-21178222
-Ref: Derived Files-Footnote-31178818
-Node: Future Extensions1178932
-Node: Implementation Limitations1179538
-Node: Extension Design1180786
-Node: Old Extension Problems1181940
-Ref: Old Extension Problems-Footnote-11183457
-Node: Extension New Mechanism Goals1183514
-Ref: Extension New Mechanism Goals-Footnote-11186874
-Node: Extension Other Design Decisions1187063
-Node: Extension Future Growth1189171
-Node: Old Extension Mechanism1190007
-Node: Notes summary1191769
-Node: Basic Concepts1192955
-Node: Basic High Level1193636
-Ref: figure-general-flow1193908
-Ref: figure-process-flow1194507
-Ref: Basic High Level-Footnote-11197736
-Node: Basic Data Typing1197921
-Node: Glossary1201249
-Node: Copying1233178
-Node: GNU Free Documentation License1270734
-Node: Index1295870
+Ref: Numeric Functions-Footnote-1513892
+Ref: Numeric Functions-Footnote-2514249
+Ref: Numeric Functions-Footnote-3514297
+Node: String Functions514569
+Ref: String Functions-Footnote-1538070
+Ref: String Functions-Footnote-2538199
+Ref: String Functions-Footnote-3538447
+Node: Gory Details538534
+Ref: table-sub-escapes540315
+Ref: table-sub-proposed541830
+Ref: table-posix-sub543192
+Ref: table-gensub-escapes544729
+Ref: Gory Details-Footnote-1545562
+Node: I/O Functions545713
+Ref: I/O Functions-Footnote-1552949
+Node: Time Functions553096
+Ref: Time Functions-Footnote-1563605
+Ref: Time Functions-Footnote-2563673
+Ref: Time Functions-Footnote-3563831
+Ref: Time Functions-Footnote-4563942
+Ref: Time Functions-Footnote-5564054
+Ref: Time Functions-Footnote-6564281
+Node: Bitwise Functions564547
+Ref: table-bitwise-ops565109
+Ref: Bitwise Functions-Footnote-1569437
+Node: Type Functions569609
+Node: I18N Functions570761
+Node: User-defined572408
+Node: Definition Syntax573213
+Ref: Definition Syntax-Footnote-1578872
+Node: Function Example578943
+Ref: Function Example-Footnote-1581864
+Node: Function Caveats581886
+Node: Calling A Function582404
+Node: Variable Scope583362
+Node: Pass By Value/Reference586355
+Node: Return Statement589852
+Node: Dynamic Typing592831
+Node: Indirect Calls593760
+Ref: Indirect Calls-Footnote-1604003
+Node: Functions Summary604131
+Node: Library Functions606833
+Ref: Library Functions-Footnote-1610441
+Ref: Library Functions-Footnote-2610584
+Node: Library Names610755
+Ref: Library Names-Footnote-1614213
+Ref: Library Names-Footnote-2614436
+Node: General Functions614522
+Node: Strtonum Function615625
+Node: Assert Function618647
+Node: Round Function621971
+Node: Cliff Random Function623512
+Node: Ordinal Functions624528
+Ref: Ordinal Functions-Footnote-1627591
+Ref: Ordinal Functions-Footnote-2627843
+Node: Join Function628054
+Ref: Join Function-Footnote-1629824
+Node: Getlocaltime Function630024
+Node: Readfile Function633768
+Node: Shell Quoting635740
+Node: Data File Management637141
+Node: Filetrans Function637773
+Node: Rewind Function641869
+Node: File Checking643255
+Ref: File Checking-Footnote-1644588
+Node: Empty Files644789
+Node: Ignoring Assigns646768
+Node: Getopt Function648318
+Ref: Getopt Function-Footnote-1659782
+Node: Passwd Functions659982
+Ref: Passwd Functions-Footnote-1668822
+Node: Group Functions668910
+Ref: Group Functions-Footnote-1676807
+Node: Walking Arrays677012
+Node: Library Functions Summary680018
+Node: Library Exercises681420
+Node: Sample Programs682700
+Node: Running Examples683470
+Node: Clones684198
+Node: Cut Program685422
+Node: Egrep Program695142
+Ref: Egrep Program-Footnote-1702645
+Node: Id Program702755
+Node: Split Program706431
+Ref: Split Program-Footnote-1709885
+Node: Tee Program710013
+Node: Uniq Program712802
+Node: Wc Program720221
+Ref: Wc Program-Footnote-1724471
+Node: Miscellaneous Programs724565
+Node: Dupword Program725778
+Node: Alarm Program727809
+Node: Translate Program732614
+Ref: Translate Program-Footnote-1737177
+Node: Labels Program737447
+Ref: Labels Program-Footnote-1740798
+Node: Word Sorting740882
+Node: History Sorting744952
+Node: Extract Program746787
+Node: Simple Sed754311
+Node: Igawk Program757381
+Ref: Igawk Program-Footnote-1771707
+Ref: Igawk Program-Footnote-2771908
+Ref: Igawk Program-Footnote-3772030
+Node: Anagram Program772145
+Node: Signature Program775206
+Node: Programs Summary776453
+Node: Programs Exercises777674
+Ref: Programs Exercises-Footnote-1781805
+Node: Advanced Features781896
+Node: Nondecimal Data783878
+Node: Array Sorting785468
+Node: Controlling Array Traversal786168
+Ref: Controlling Array Traversal-Footnote-1794534
+Node: Array Sorting Functions794652
+Ref: Array Sorting Functions-Footnote-1798538
+Node: Two-way I/O798734
+Ref: Two-way I/O-Footnote-1803679
+Ref: Two-way I/O-Footnote-2803865
+Node: TCP/IP Networking803947
+Node: Profiling806819
+Node: Advanced Features Summary815090
+Node: Internationalization817023
+Node: I18N and L10N818503
+Node: Explaining gettext819189
+Ref: Explaining gettext-Footnote-1824214
+Ref: Explaining gettext-Footnote-2824398
+Node: Programmer i18n824563
+Ref: Programmer i18n-Footnote-1829439
+Node: Translator i18n829488
+Node: String Extraction830282
+Ref: String Extraction-Footnote-1831413
+Node: Printf Ordering831499
+Ref: Printf Ordering-Footnote-1834285
+Node: I18N Portability834349
+Ref: I18N Portability-Footnote-1836805
+Node: I18N Example836868
+Ref: I18N Example-Footnote-1839671
+Node: Gawk I18N839743
+Node: I18N Summary840387
+Node: Debugger841727
+Node: Debugging842749
+Node: Debugging Concepts843190
+Node: Debugging Terms845000
+Node: Awk Debugging847572
+Node: Sample Debugging Session848478
+Node: Debugger Invocation849012
+Node: Finding The Bug850397
+Node: List of Debugger Commands856876
+Node: Breakpoint Control858208
+Node: Debugger Execution Control861885
+Node: Viewing And Changing Data865244
+Node: Execution Stack868620
+Node: Debugger Info870255
+Node: Miscellaneous Debugger Commands874300
+Node: Readline Support879301
+Node: Limitations880195
+Node: Debugging Summary882310
+Node: Arbitrary Precision Arithmetic883484
+Node: Computer Arithmetic884900
+Ref: table-numeric-ranges888477
+Ref: Computer Arithmetic-Footnote-1889001
+Node: Math Definitions889058
+Ref: table-ieee-formats892353
+Ref: Math Definitions-Footnote-1892957
+Node: MPFR features893062
+Node: FP Math Caution894733
+Ref: FP Math Caution-Footnote-1895783
+Node: Inexactness of computations896152
+Node: Inexact representation897111
+Node: Comparing FP Values898469
+Node: Errors accumulate899551
+Node: Getting Accuracy900983
+Node: Try To Round903687
+Node: Setting precision904586
+Ref: table-predefined-precision-strings905270
+Node: Setting the rounding mode907099
+Ref: table-gawk-rounding-modes907463
+Ref: Setting the rounding mode-Footnote-1910915
+Node: Arbitrary Precision Integers911094
+Ref: Arbitrary Precision Integers-Footnote-1915992
+Node: POSIX Floating Point Problems916141
+Ref: POSIX Floating Point Problems-Footnote-1920020
+Node: Floating point summary920058
+Node: Dynamic Extensions922245
+Node: Extension Intro923797
+Node: Plugin License925062
+Node: Extension Mechanism Outline925859
+Ref: figure-load-extension926287
+Ref: figure-register-new-function927767
+Ref: figure-call-new-function928771
+Node: Extension API Description930758
+Node: Extension API Functions Introduction932292
+Node: General Data Types937161
+Ref: General Data Types-Footnote-1943061
+Node: Memory Allocation Functions943360
+Ref: Memory Allocation Functions-Footnote-1946199
+Node: Constructor Functions946298
+Node: Registration Functions948037
+Node: Extension Functions948722
+Node: Exit Callback Functions951019
+Node: Extension Version String952267
+Node: Input Parsers952930
+Node: Output Wrappers962805
+Node: Two-way processors967318
+Node: Printing Messages969581
+Ref: Printing Messages-Footnote-1970657
+Node: Updating `ERRNO'970809
+Node: Requesting Values971549
+Ref: table-value-types-returned972276
+Node: Accessing Parameters973233
+Node: Symbol Table Access974467
+Node: Symbol table by name974981
+Node: Symbol table by cookie977001
+Ref: Symbol table by cookie-Footnote-1981146
+Node: Cached values981209
+Ref: Cached values-Footnote-1984705
+Node: Array Manipulation984796
+Ref: Array Manipulation-Footnote-1985886
+Node: Array Data Types985923
+Ref: Array Data Types-Footnote-1988578
+Node: Array Functions988670
+Node: Flattening Arrays992529
+Node: Creating Arrays999431
+Node: Redirection API1004202
+Node: Extension API Variables1007027
+Node: Extension Versioning1007660
+Node: Extension API Informational Variables1009551
+Node: Extension API Boilerplate1010616
+Node: Finding Extensions1014425
+Node: Extension Example1014985
+Node: Internal File Description1015757
+Node: Internal File Ops1019824
+Ref: Internal File Ops-Footnote-11031575
+Node: Using Internal File Ops1031715
+Ref: Using Internal File Ops-Footnote-11034098
+Node: Extension Samples1034371
+Node: Extension Sample File Functions1035899
+Node: Extension Sample Fnmatch1043580
+Node: Extension Sample Fork1045068
+Node: Extension Sample Inplace1046283
+Node: Extension Sample Ord1048369
+Node: Extension Sample Readdir1049205
+Ref: table-readdir-file-types1050082
+Node: Extension Sample Revout1050893
+Node: Extension Sample Rev2way1051482
+Node: Extension Sample Read write array1052222
+Node: Extension Sample Readfile1054162
+Node: Extension Sample Time1055257
+Node: Extension Sample API Tests1056605
+Node: gawkextlib1057096
+Node: Extension summary1059797
+Node: Extension Exercises1063486
+Node: Language History1064982
+Node: V7/SVR3.11066638
+Node: SVR41068791
+Node: POSIX1070225
+Node: BTL1071606
+Node: POSIX/GNU1072337
+Node: Feature History1078173
+Node: Common Extensions1091967
+Node: Ranges and Locales1093339
+Ref: Ranges and Locales-Footnote-11097958
+Ref: Ranges and Locales-Footnote-21097985
+Ref: Ranges and Locales-Footnote-31098220
+Node: Contributors1098441
+Node: History summary1103981
+Node: Installation1105360
+Node: Gawk Distribution1106306
+Node: Getting1106790
+Node: Extracting1107613
+Node: Distribution contents1109250
+Node: Unix Installation1115352
+Node: Quick Installation1116035
+Node: Shell Startup Files1118446
+Node: Additional Configuration Options1119525
+Node: Configuration Philosophy1121329
+Node: Non-Unix Installation1123698
+Node: PC Installation1124156
+Node: PC Binary Installation1125476
+Node: PC Compiling1127324
+Ref: PC Compiling-Footnote-11130345
+Node: PC Testing1130454
+Node: PC Using1131630
+Node: Cygwin1135745
+Node: MSYS1136515
+Node: VMS Installation1137016
+Node: VMS Compilation1137808
+Ref: VMS Compilation-Footnote-11139037
+Node: VMS Dynamic Extensions1139095
+Node: VMS Installation Details1140779
+Node: VMS Running1143030
+Node: VMS GNV1145870
+Node: VMS Old Gawk1146605
+Node: Bugs1147075
+Node: Other Versions1150964
+Node: Installation summary1157398
+Node: Notes1158457
+Node: Compatibility Mode1159322
+Node: Additions1160104
+Node: Accessing The Source1161029
+Node: Adding Code1162464
+Node: New Ports1168621
+Node: Derived Files1173103
+Ref: Derived Files-Footnote-11178578
+Ref: Derived Files-Footnote-21178612
+Ref: Derived Files-Footnote-31179208
+Node: Future Extensions1179322
+Node: Implementation Limitations1179928
+Node: Extension Design1181176
+Node: Old Extension Problems1182330
+Ref: Old Extension Problems-Footnote-11183847
+Node: Extension New Mechanism Goals1183904
+Ref: Extension New Mechanism Goals-Footnote-11187264
+Node: Extension Other Design Decisions1187453
+Node: Extension Future Growth1189561
+Node: Old Extension Mechanism1190397
+Node: Notes summary1192159
+Node: Basic Concepts1193345
+Node: Basic High Level1194026
+Ref: figure-general-flow1194298
+Ref: figure-process-flow1194897
+Ref: Basic High Level-Footnote-11198126
+Node: Basic Data Typing1198311
+Node: Glossary1201639
+Node: Copying1233568
+Node: GNU Free Documentation License1271124
+Node: Index1296260

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index e0b44fa1..f710d725 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -17153,8 +17153,8 @@ function randint(n)
@end example
@noindent
-The multiplication produces a random number greater than zero and less
-than @code{n}. Using @code{int()}, this result is made into
+The multiplication produces a random number greater than or equal to
+zero and less than @code{n}. Using @code{int()}, this result is made into
an integer between zero and @code{n} @minus{} 1, inclusive.
The following example uses a similar function to produce random integers
@@ -20506,10 +20506,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 f8642fca..4e2b67d7 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -16435,8 +16435,8 @@ function randint(n)
@end example
@noindent
-The multiplication produces a random number greater than zero and less
-than @code{n}. Using @code{int()}, this result is made into
+The multiplication produces a random number greater than or equal to
+zero and less than @code{n}. Using @code{int()}, this result is made into
an integer between zero and @code{n} @minus{} 1, inclusive.
The following example uses a similar function to produce random integers
@@ -19627,10 +19627,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/eval.c b/eval.c
index 887b80f8..c63dd170 100644
--- a/eval.c
+++ b/eval.c
@@ -1183,7 +1183,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 dee53957..a11268de 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 8aedf6f2..0c21218e 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-31 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.am (indirectbuiltin): New test.
+ * indirectbuiltin.awk, indirectbuiltin.ok: New files.
+
2015-03-27 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am: Remove defvar test and reference to files; test
@@ -5,6 +10,10 @@
* defvar.awk, defvar.ok: Removed.
* testext.ok: Updated.
+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 788fff5e..b45eaf95 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -436,6 +436,8 @@ EXTRA_DIST = \
include.awk \
include.ok \
include2.ok \
+ indirectbuiltin.awk \
+ indirectbuiltin.ok \
indirectcall.awk \
indirectcall.in \
indirectcall.ok \
@@ -1062,7 +1064,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 ad27412a..8053df5c 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -693,6 +693,8 @@ EXTRA_DIST = \
include.awk \
include.ok \
include2.ok \
+ indirectbuiltin.awk \
+ indirectbuiltin.ok \
indirectcall.awk \
indirectcall.in \
indirectcall.ok \
@@ -1318,7 +1320,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 \
@@ -3632,6 +3634,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 f3d048ed..219d592d 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: $$? >>_$@
diff --git a/test/id.ok b/test/id.ok
index fb77f457..b5baf15a 100644
--- a/test/id.ok
+++ b/test/id.ok
@@ -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