summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2015-04-03 09:17:01 +0300
committerArnold D. Robbins <arnold@skeeve.com>2015-04-03 09:17:01 +0300
commit91ac42ccd9bbeee4f17181cd896cc9b7de13b6f7 (patch)
tree35399cf252627fdbcb0d54d959f9eaf560db7193
parent3fad6ad12e1637c4e1b72fbeaf0265f44da0cf27 (diff)
parentddc290584b39bab2c1edcec935a31ea12d343246 (diff)
downloadgawk-wasted-byte.tar.gz
Merge branch 'master' into wasted-bytewasted-byte
-rw-r--r--ChangeLog45
-rw-r--r--awk.h9
-rw-r--r--awkgram.c745
-rw-r--r--awkgram.y27
-rw-r--r--awklib/eg/lib/intdiv.awk (renamed from awklib/eg/lib/div.awk)7
-rw-r--r--awklib/eg/prog/pi.awk2
-rw-r--r--builtin.c152
-rw-r--r--doc/ChangeLog10
-rw-r--r--doc/awkcard.in6
-rw-r--r--doc/gawk.116
-rw-r--r--doc/gawk.info991
-rw-r--r--doc/gawk.texi96
-rw-r--r--doc/gawktexi.in96
-rw-r--r--eval.c2
-rw-r--r--interpret.h10
-rw-r--r--mpfr.c12
-rw-r--r--test/ChangeLog13
-rw-r--r--test/Makefile.am4
-rw-r--r--test/Makefile.in9
-rw-r--r--test/Maketests5
-rw-r--r--test/id.ok3
-rw-r--r--test/indirectbuiltin.awk371
-rw-r--r--test/indirectbuiltin.ok43
-rw-r--r--test/mpfrsqrt.awk6
24 files changed, 1705 insertions, 975 deletions
diff --git a/ChangeLog b/ChangeLog
index c123e91e..79e0f1fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,43 @@
+2015-04-02 Arnold D. Robbins <arnold@skeeve.com>
+
+ Rename div() to intdiv().
+
+ * builtin.c (do_intdiv): Renamed from do_div.
+ * mfpr.c (do_mpfr_intdiv): Renamed from do_mpfr_div.
+ * awk.h: Update declarations.
+ * awkgram.y (tokentab, snode): Revise accordingly.
+
+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 +47,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..6f812e71 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);
@@ -1379,7 +1383,7 @@ extern AWKNUM nondec2awknum(char *str, size_t len);
extern NODE *do_dcgettext(int nargs);
extern NODE *do_dcngettext(int nargs);
extern NODE *do_bindtextdomain(int nargs);
-extern NODE *do_div(int nargs);
+extern NODE *do_intdiv(int nargs);
extern int strncasecmpmbs(const unsigned char *,
const unsigned char *, size_t);
/* eval.c */
@@ -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 */
@@ -1521,9 +1526,9 @@ extern NODE *do_mpfr_and(int);
extern NODE *do_mpfr_atan2(int);
extern NODE *do_mpfr_compl(int);
extern NODE *do_mpfr_cos(int);
-extern NODE *do_mpfr_div(int);
extern NODE *do_mpfr_exp(int);
extern NODE *do_mpfr_int(int);
+extern NODE *do_mpfr_intdiv(int);
extern NODE *do_mpfr_log(int);
extern NODE *do_mpfr_lshift(int);
extern NODE *do_mpfr_or(int);
diff --git a/awkgram.c b/awkgram.c
index ad012b1d..02c6e41b 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 {
@@ -4288,7 +4287,6 @@ static const struct token tokentab[] = {
{"dcngettext", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3)|A(4)|A(5), do_dcngettext, 0},
{"default", Op_K_default, LEX_DEFAULT, GAWKX, 0, 0},
{"delete", Op_K_delete, LEX_DELETE, NOT_OLD, 0, 0},
-{"div", Op_builtin, LEX_BUILTIN, GAWKX|A(3), do_div, MPF(div)},
{"do", Op_K_do, LEX_DO, NOT_OLD|BREAK|CONTINUE, 0, 0},
{"else", Op_K_else, LEX_ELSE, 0, 0, 0},
{"eval", Op_symbol, LEX_EVAL, 0, 0, 0},
@@ -4309,6 +4307,7 @@ static const struct token tokentab[] = {
{"include", Op_symbol, LEX_INCLUDE, GAWKX, 0, 0},
{"index", Op_builtin, LEX_BUILTIN, A(2), do_index, 0},
{"int", Op_builtin, LEX_BUILTIN, A(1), do_int, MPF(int)},
+{"intdiv", Op_builtin, LEX_BUILTIN, GAWKX|A(3), do_intdiv, MPF(intdiv)},
{"isarray", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_isarray, 0},
{"length", Op_builtin, LEX_LENGTH, A(0)|A(1), do_length, 0},
{"load", Op_symbol, LEX_LOAD, GAWKX, 0, 0},
@@ -6482,9 +6481,9 @@ snode(INSTRUCTION *subn, INSTRUCTION *r)
arg = subn->nexti;
if (arg->nexti == arg->lasti && arg->nexti->opcode == Op_push)
arg->nexti->opcode = Op_push_arg; /* argument may be array */
- } else if (r->builtin == do_div
+ } else if (r->builtin == do_intdiv
#ifdef HAVE_MPFR
- || r->builtin == MPF(div)
+ || r->builtin == MPF(intdiv)
#endif
) {
arg = subn->nexti->lasti->nexti->lasti->nexti; /* 3rd arg list */
@@ -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 067a933f..d723f510 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);
@@ -1950,7 +1949,6 @@ static const struct token tokentab[] = {
{"dcngettext", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3)|A(4)|A(5), do_dcngettext, 0},
{"default", Op_K_default, LEX_DEFAULT, GAWKX, 0, 0},
{"delete", Op_K_delete, LEX_DELETE, NOT_OLD, 0, 0},
-{"div", Op_builtin, LEX_BUILTIN, GAWKX|A(3), do_div, MPF(div)},
{"do", Op_K_do, LEX_DO, NOT_OLD|BREAK|CONTINUE, 0, 0},
{"else", Op_K_else, LEX_ELSE, 0, 0, 0},
{"eval", Op_symbol, LEX_EVAL, 0, 0, 0},
@@ -1971,6 +1969,7 @@ static const struct token tokentab[] = {
{"include", Op_symbol, LEX_INCLUDE, GAWKX, 0, 0},
{"index", Op_builtin, LEX_BUILTIN, A(2), do_index, 0},
{"int", Op_builtin, LEX_BUILTIN, A(1), do_int, MPF(int)},
+{"intdiv", Op_builtin, LEX_BUILTIN, GAWKX|A(3), do_intdiv, MPF(intdiv)},
{"isarray", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_isarray, 0},
{"length", Op_builtin, LEX_LENGTH, A(0)|A(1), do_length, 0},
{"load", Op_symbol, LEX_LOAD, GAWKX, 0, 0},
@@ -4144,9 +4143,9 @@ snode(INSTRUCTION *subn, INSTRUCTION *r)
arg = subn->nexti;
if (arg->nexti == arg->lasti && arg->nexti->opcode == Op_push)
arg->nexti->opcode = Op_push_arg; /* argument may be array */
- } else if (r->builtin == do_div
+ } else if (r->builtin == do_intdiv
#ifdef HAVE_MPFR
- || r->builtin == MPF(div)
+ || r->builtin == MPF(intdiv)
#endif
) {
arg = subn->nexti->lasti->nexti->lasti->nexti; /* 3rd arg list */
@@ -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/awklib/eg/lib/div.awk b/awklib/eg/lib/intdiv.awk
index 5939024d..dbc553b0 100644
--- a/awklib/eg/lib/div.awk
+++ b/awklib/eg/lib/intdiv.awk
@@ -1,10 +1,13 @@
-# div --- do integer division
+# intdiv --- do integer division
#
# Arnold Robbins, arnold@skeeve.com, Public Domain
# July, 2014
+#
+# Name changed from div() to intdiv()
+# April, 2015
-function div(numerator, denominator, result)
+function intdiv(numerator, denominator, result)
{
split("", result)
diff --git a/awklib/eg/prog/pi.awk b/awklib/eg/prog/pi.awk
index 3297beff..e1b5bc4f 100644
--- a/awklib/eg/prog/pi.awk
+++ b/awklib/eg/prog/pi.awk
@@ -10,7 +10,7 @@ BEGIN {
for (m = digits * 4; m > 0; --m) {
d = m * 2 + 1
x = pi * m
- div(x, d, result)
+ intdiv(x, d, result)
pi = result["quotient"]
pi = pi + two
}
diff --git a/builtin.c b/builtin.c
index 88fced6b..38a5646b 100644
--- a/builtin.c
+++ b/builtin.c
@@ -3071,6 +3071,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. */
@@ -3611,7 +3751,7 @@ do_bindtextdomain(int nargs)
return make_string(the_result, strlen(the_result));
}
-/* do_div --- do integer division, return quotient and remainder in dest array */
+/* do_intdiv --- do integer division, return quotient and remainder in dest array */
/*
* We define the semantics as:
@@ -3622,7 +3762,7 @@ do_bindtextdomain(int nargs)
*/
NODE *
-do_div(int nargs)
+do_intdiv(int nargs)
{
NODE *numerator, *denominator, *result;
double num, denom, quotient, remainder;
@@ -3630,7 +3770,7 @@ do_div(int nargs)
result = POP_PARAM();
if (result->type != Node_var_array)
- fatal(_("div: third argument is not an array"));
+ fatal(_("intdiv: third argument is not an array"));
assoc_clear(result);
denominator = POP_SCALAR();
@@ -3638,9 +3778,9 @@ do_div(int nargs)
if (do_lint) {
if ((numerator->flags & (NUMCUR|NUMBER)) == 0)
- lintwarn(_("div: received non-numeric first argument"));
+ lintwarn(_("intdiv: received non-numeric first argument"));
if ((denominator->flags & (NUMCUR|NUMBER)) == 0)
- lintwarn(_("div: received non-numeric second argument"));
+ lintwarn(_("intdiv: received non-numeric second argument"));
}
(void) force_number(numerator);
@@ -3649,7 +3789,7 @@ do_div(int nargs)
denom = double_to_int(get_number_d(denominator));
if (denom == 0.0)
- fatal(_("div: division by zero attempted"));
+ fatal(_("intdiv: division by zero attempted"));
quotient = double_to_int(num / denom);
/*
diff --git a/doc/ChangeLog b/doc/ChangeLog
index f4a6f19b..0e88c869 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,13 @@
+2015-04-02 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in, gawk.1, awkcard.in: Name change: div() --> intdiv().
+
+2015-03-31 Arnold D. Robbins <arnold@skeeve.com>
+
+ * 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>
* gawktexi.in: Minor edits.
diff --git a/doc/awkcard.in b/doc/awkcard.in
index 556bdc1e..2e455b2d 100644
--- a/doc/awkcard.in
+++ b/doc/awkcard.in
@@ -1609,11 +1609,11 @@ expand;
l lw(2i).
\*(CD\*(FCatan2(\*(FIy\*(FC, \*(FIx\*(FC)\*(FR The arctangent of \*(FIy/x\fP in radians.
\*(FCcos(\*(FIexpr\*(FC)\*(FR The cosine of \*(FIexpr\fP, which is in radians.
-\*(CB\*(FCdiv(\*(FIn\*(FR\*(FC,\*(FI d\*(FR\*(FC,\*(FI res\*(FR\*(FC)\*(FR T{
-Return the result of integer division in \*(FIres\*(FR.\*(CD
-T}
\*(FCexp(\*(FIexpr\*(FC)\*(FR The exponential function (\*(FIe \*(FC^ \*(FIx\*(FR).
\*(FCint(\*(FIexpr\*(FC)\*(FR Truncate to integer.
+\*(CB\*(FCintdiv(\*(FIn\*(FR\*(FC,\*(FI d\*(FR\*(FC,\*(FI res\*(FR\*(FC)\*(FR T{
+Return the result of integer division in \*(FIres\*(FR.\*(CD
+T}
\*(FClog(\*(FIexpr\*(FC)\*(FR The natural logarithm function (base \*(FIe\^\*(FR).
\*(FCrand()\fP A random number \*(FIN\fP such that 0 \(<= \*(FIN\fP < 1.
\*(FCsin(\*(FIexpr\*(FC)\*(FR The sine of \*(FIexpr\fP, which is in radians.
diff --git a/doc/gawk.1 b/doc/gawk.1
index 45a4c9f2..cbc15d15 100644
--- a/doc/gawk.1
+++ b/doc/gawk.1
@@ -13,7 +13,7 @@
. if \w'\(rq' .ds rq "\(rq
. \}
.\}
-.TH GAWK 1 "Mar 24 2015" "Free Software Foundation" "Utility Commands"
+.TH GAWK 1 "Apr 02 2015" "Free Software Foundation" "Utility Commands"
.SH NAME
gawk \- pattern scanning and processing language
.SH SYNOPSIS
@@ -2680,7 +2680,13 @@ Return the cosine of
.IR expr ,
which is in radians.
.TP
-.BI div( num ", " denom ", " result )
+.BI exp( expr )
+The exponential function.
+.TP
+.BI int( expr )
+Truncate to integer.
+.TP
+.BI intdiv( num ", " denom ", " result )
Truncate
.I num
and
@@ -2697,12 +2703,6 @@ This is a
extension, primarily of value when working with
arbitrarily large integers.
.TP
-.BI exp( expr )
-The exponential function.
-.TP
-.BI int( expr )
-Truncate to integer.
-.TP
.BI log( expr )
The natural logarithm function.
.TP
diff --git a/doc/gawk.info b/doc/gawk.info
index d0312ec6..685df45b 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -6005,11 +6005,11 @@ Auto-set::):
PROCINFO["INPUT_NAME", "RETRY"] = 1
- When this element exists, `gawk' checks the value of the system
-`errno' variable when an I/O error occurs. If `errno' indicates a
-subsequent I/O attempt may succeed, `getline' instead returns -2 and
-further calls to `getline' may succeed. This applies to the `errno'
-values `EAGAIN', `EWOULDBLOCK', `EINTR', or `ETIMEDOUT'.
+ When this element exists, `gawk' checks the value of the system (C
+language) `errno' variable when an I/O error occurs. If `errno'
+indicates a subsequent I/O attempt may succeed, `getline' instead
+returns -2 and further calls to `getline' may succeed. This applies to
+the `errno' values `EAGAIN', `EWOULDBLOCK', `EINTR', or `ETIMEDOUT'.
This feature is useful in conjunction with `PROCINFO["INPUT_NAME",
"READ_TIMEOUT"]' or situations where a file descriptor has been
@@ -12031,7 +12031,17 @@ brackets ([ ]):
`cos(X)'
Return the cosine of X, with X in radians.
-`div(NUMERATOR, DENOMINATOR, RESULT)'
+`exp(X)'
+ Return the exponential of X (`e ^ X') or report an error if X is
+ out of range. The range of values X can have depends on your
+ machine's floating-point representation.
+
+`int(X)'
+ Return the nearest integer to X, located between X and zero and
+ truncated toward zero. For example, `int(3)' is 3, `int(3.9)' is
+ 3, `int(-3.9)' is -3, and `int(-3)' is -3 as well.
+
+`intdiv(NUMERATOR, DENOMINATOR, RESULT)'
Perform integer division, similar to the standard C function of the
same name. First, truncate `numerator' and `denominator' towards
zero, creating integer values. Clear the `result' array, and then
@@ -12046,16 +12056,6 @@ brackets ([ ]):
This function is a `gawk' extension. It is not available in
compatibility mode (*note Options::).
-`exp(X)'
- Return the exponential of X (`e ^ X') or report an error if X is
- out of range. The range of values X can have depends on your
- machine's floating-point representation.
-
-`int(X)'
- Return the nearest integer to X, located between X and zero and
- truncated toward zero. For example, `int(3)' is 3, `int(3.9)' is
- 3, `int(-3.9)' is -3, and `int(-3)' is -3 as well.
-
`log(X)'
Return the natural logarithm of X, if X is positive; otherwise,
return `NaN' ("not a number") on IEEE 754 systems. Additionally,
@@ -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:
@@ -22610,14 +22618,15 @@ the following:
`%', the result is typically an arbitrary precision floating point
value (unless the denominator evenly divides into the numerator). In
order to do integer division or remainder with arbitrary precision
-integers, use the built-in `div()' function (*note Numeric Functions::).
+integers, use the built-in `intdiv()' function (*note Numeric
+Functions::).
- You can simulate the `div()' function in standard `awk' using this
-user-defined function:
+ You can simulate the `intdiv()' function in standard `awk' using
+this user-defined function:
- # div --- do integer division
+ # intdiv --- do integer division
- function div(numerator, denominator, result)
+ function intdiv(numerator, denominator, result)
{
split("", result)
@@ -22630,8 +22639,8 @@ user-defined function:
}
The following example program, contributed by Katie Wasserman, uses
-`div()' to compute the digits of pi to as many places as you choose to
-set:
+`intdiv()' to compute the digits of pi to as many places as you choose
+to set:
# pi.awk --- compute the digits of pi
@@ -22642,7 +22651,7 @@ set:
for (m = digits * 4; m > 0; --m) {
d = m * 2 + 1
x = pi * m
- div(x, d, result)
+ intdiv(x, d, result)
pi = result["quotient"]
pi = pi + two
}
@@ -26259,15 +26268,17 @@ project.
* GD graphics library extension
+ * MPFR library extension (this provides access to a number of MPFR
+ functions that `gawk''s native MPFR support does not)
+
* PDF extension
* PostgreSQL extension
- * MPFR library extension (this provides access to a number of MPFR
- functions that `gawk''s native MPFR support does not)
-
* Redis extension
+ * Select extension
+
* XML parser extension, using the Expat
(http://expat.sourceforge.net) XML parsing library
@@ -26742,8 +26753,8 @@ the current version of `gawk'.
- The `bindtextdomain()', `dcgettext()', and `dcngettext()'
functions for internationalization (*note Programmer i18n::)
- - The `div()' function for doing integer division and remainder
- (*note Numeric Functions::)
+ - The `intdiv()' function for doing integer division and
+ remainder (*note Numeric Functions::)
* Changes and/or additions in the command-line options:
@@ -27203,7 +27214,7 @@ in POSIX `awk', in the order they were added to `gawk'.
* The `igawk' program and its manual page are no longer installed
when `gawk' is built. *Note Igawk Program::.
- * The `div()' function. *Note Numeric Functions::.
+ * The `intdiv()' function. *Note Numeric Functions::.
* The maximum number of hexdecimal digits in `\x' escapes is now two.
*Note Escape Sequences::.
@@ -32931,7 +32942,6 @@ Index
* display debugger command: Viewing And Changing Data.
(line 8)
* display debugger options: Debugger Info. (line 57)
-* div: Numeric Functions. (line 18)
* division: Arithmetic Ops. (line 44)
* do-while statement: Do Statement. (line 6)
* do-while statement, use of regexps in: Regexp Usage. (line 19)
@@ -33051,10 +33061,10 @@ Index
* exit status, of VMS: VMS Running. (line 28)
* exit the debugger: Miscellaneous Debugger Commands.
(line 99)
-* exp: Numeric Functions. (line 33)
+* exp: Numeric Functions. (line 18)
* expand utility: Very Simple. (line 73)
-* Expat XML parser library: gawkextlib. (line 35)
-* exponent: Numeric Functions. (line 33)
+* Expat XML parser library: gawkextlib. (line 37)
+* exponent: Numeric Functions. (line 18)
* expressions: Expressions. (line 6)
* expressions, as patterns: Expression Patterns. (line 6)
* expressions, assignment: Assignment Ops. (line 6)
@@ -33473,7 +33483,7 @@ Index
* git utility <2>: Accessing The Source.
(line 10)
* git utility <3>: Other Versions. (line 29)
-* git utility: gawkextlib. (line 29)
+* git utility: gawkextlib. (line 31)
* Git, use of for gawk source code: Derived Files. (line 6)
* GNITS mailing list: Acknowledgments. (line 52)
* GNU awk, See gawk: Preface. (line 51)
@@ -33598,8 +33608,9 @@ Index
* installation, VMS: VMS Installation. (line 6)
* installing gawk: Installation. (line 6)
* instruction tracing, in debugger: Debugger Info. (line 90)
-* int: Numeric Functions. (line 38)
+* int: Numeric Functions. (line 23)
* INT signal (MS-Windows): Profiling. (line 213)
+* intdiv: Numeric Functions. (line 28)
* integer array indices: Numeric Array Subscripts.
(line 31)
* integers, arbitrary precision: Arbitrary Precision Integers.
@@ -34339,7 +34350,7 @@ Index
* Robbins, Miriam <2>: Getline/Pipe. (line 39)
* Robbins, Miriam: Acknowledgments. (line 94)
* Rommel, Kai Uwe: Contributors. (line 42)
-* round to nearest integer: Numeric Functions. (line 38)
+* round to nearest integer: Numeric Functions. (line 23)
* round() user-defined function: Round Function. (line 16)
* rounding numbers: Round Function. (line 6)
* ROUNDMODE variable: User-modified. (line 127)
@@ -34997,452 +35008,452 @@ Ref: table-getline-variants261262
Node: Read Timeout262091
Ref: Read Timeout-Footnote-1265994
Node: Retrying Input266052
-Node: Command-line directories267238
-Node: Input Summary268145
-Node: Input Exercises271530
-Node: Printing272258
-Node: Print274093
-Node: Print Examples275550
-Node: Output Separators278329
-Node: OFMT280347
-Node: Printf281702
-Node: Basic Printf282487
-Node: Control Letters284059
-Node: Format Modifiers288044
-Node: Printf Examples294050
-Node: Redirection296536
-Node: Special FD303374
-Ref: Special FD-Footnote-1306540
-Node: Special Files306614
-Node: Other Inherited Files307231
-Node: Special Network308231
-Node: Special Caveats309093
-Node: Close Files And Pipes310042
-Ref: Close Files And Pipes-Footnote-1317227
-Ref: Close Files And Pipes-Footnote-2317375
-Node: Nonfatal317525
-Node: Output Summary319850
-Node: Output Exercises321071
-Node: Expressions321751
-Node: Values322940
-Node: Constants323617
-Node: Scalar Constants324308
-Ref: Scalar Constants-Footnote-1325170
-Node: Nondecimal-numbers325420
-Node: Regexp Constants328430
-Node: Using Constant Regexps328956
-Node: Variables332119
-Node: Using Variables332776
-Node: Assignment Options334687
-Node: Conversion336562
-Node: Strings And Numbers337086
-Ref: Strings And Numbers-Footnote-1340151
-Node: Locale influences conversions340260
-Ref: table-locale-affects343006
-Node: All Operators343598
-Node: Arithmetic Ops344227
-Node: Concatenation346732
-Ref: Concatenation-Footnote-1349551
-Node: Assignment Ops349658
-Ref: table-assign-ops354637
-Node: Increment Ops355947
-Node: Truth Values and Conditions359378
-Node: Truth Values360461
-Node: Typing and Comparison361510
-Node: Variable Typing362326
-Node: Comparison Operators365993
-Ref: table-relational-ops366403
-Node: POSIX String Comparison369898
-Ref: POSIX String Comparison-Footnote-1370970
-Node: Boolean Ops371109
-Ref: Boolean Ops-Footnote-1375587
-Node: Conditional Exp375678
-Node: Function Calls377416
-Node: Precedence381296
-Node: Locales384956
-Node: Expressions Summary386588
-Node: Patterns and Actions389159
-Node: Pattern Overview390279
-Node: Regexp Patterns391958
-Node: Expression Patterns392501
-Node: Ranges396281
-Node: BEGIN/END399388
-Node: Using BEGIN/END400149
-Ref: Using BEGIN/END-Footnote-1402885
-Node: I/O And BEGIN/END402991
-Node: BEGINFILE/ENDFILE405306
-Node: Empty408203
-Node: Using Shell Variables408520
-Node: Action Overview410793
-Node: Statements413119
-Node: If Statement414967
-Node: While Statement416462
-Node: Do Statement418490
-Node: For Statement419638
-Node: Switch Statement422796
-Node: Break Statement425178
-Node: Continue Statement427271
-Node: Next Statement429098
-Node: Nextfile Statement431479
-Node: Exit Statement434107
-Node: Built-in Variables436518
-Node: User-modified437651
-Ref: User-modified-Footnote-1445285
-Node: Auto-set445347
-Ref: Auto-set-Footnote-1459580
-Ref: Auto-set-Footnote-2459785
-Node: ARGC and ARGV459841
-Node: Pattern Action Summary464059
-Node: Arrays466492
-Node: Array Basics467821
-Node: Array Intro468665
-Ref: figure-array-elements470602
-Ref: Array Intro-Footnote-1473225
-Node: Reference to Elements473353
-Node: Assigning Elements475815
-Node: Array Example476306
-Node: Scanning an Array478065
-Node: Controlling Scanning481088
-Ref: Controlling Scanning-Footnote-1486482
-Node: Numeric Array Subscripts486798
-Node: Uninitialized Subscripts488983
-Node: Delete490600
-Ref: Delete-Footnote-1493349
-Node: Multidimensional493406
-Node: Multiscanning496503
-Node: Arrays of Arrays498092
-Node: Arrays Summary502846
-Node: Functions504937
-Node: Built-in505976
-Node: Calling Built-in507054
-Node: Numeric Functions509049
-Ref: Numeric Functions-Footnote-1513867
-Ref: Numeric Functions-Footnote-2514224
-Ref: Numeric Functions-Footnote-3514272
-Node: String Functions514544
-Ref: String Functions-Footnote-1538045
-Ref: String Functions-Footnote-2538174
-Ref: String Functions-Footnote-3538422
-Node: Gory Details538509
-Ref: table-sub-escapes540290
-Ref: table-sub-proposed541805
-Ref: table-posix-sub543167
-Ref: table-gensub-escapes544704
-Ref: Gory Details-Footnote-1545537
-Node: I/O Functions545688
-Ref: I/O Functions-Footnote-1552924
-Node: Time Functions553071
-Ref: Time Functions-Footnote-1563580
-Ref: Time Functions-Footnote-2563648
-Ref: Time Functions-Footnote-3563806
-Ref: Time Functions-Footnote-4563917
-Ref: Time Functions-Footnote-5564029
-Ref: Time Functions-Footnote-6564256
-Node: Bitwise Functions564522
-Ref: table-bitwise-ops565084
-Ref: Bitwise Functions-Footnote-1569412
-Node: Type Functions569584
-Node: I18N Functions570736
-Node: User-defined572383
-Node: Definition Syntax573188
-Ref: Definition Syntax-Footnote-1578847
-Node: Function Example578918
-Ref: Function Example-Footnote-1581839
-Node: Function Caveats581861
-Node: Calling A Function582379
-Node: Variable Scope583337
-Node: Pass By Value/Reference586330
-Node: Return Statement589827
-Node: Dynamic Typing592806
-Node: Indirect Calls593735
-Ref: Indirect Calls-Footnote-1603600
-Node: Functions Summary603728
-Node: Library Functions606430
-Ref: Library Functions-Footnote-1610038
-Ref: Library Functions-Footnote-2610181
-Node: Library Names610352
-Ref: Library Names-Footnote-1613810
-Ref: Library Names-Footnote-2614033
-Node: General Functions614119
-Node: Strtonum Function615222
-Node: Assert Function618244
-Node: Round Function621568
-Node: Cliff Random Function623109
-Node: Ordinal Functions624125
-Ref: Ordinal Functions-Footnote-1627188
-Ref: Ordinal Functions-Footnote-2627440
-Node: Join Function627651
-Ref: Join Function-Footnote-1629421
-Node: Getlocaltime Function629621
-Node: Readfile Function633365
-Node: Shell Quoting635337
-Node: Data File Management636738
-Node: Filetrans Function637370
-Node: Rewind Function641466
-Node: File Checking642852
-Ref: File Checking-Footnote-1644185
-Node: Empty Files644386
-Node: Ignoring Assigns646365
-Node: Getopt Function647915
-Ref: Getopt Function-Footnote-1659379
-Node: Passwd Functions659579
-Ref: Passwd Functions-Footnote-1668419
-Node: Group Functions668507
-Ref: Group Functions-Footnote-1676404
-Node: Walking Arrays676609
-Node: Library Functions Summary679615
-Node: Library Exercises681017
-Node: Sample Programs682297
-Node: Running Examples683067
-Node: Clones683795
-Node: Cut Program685019
-Node: Egrep Program694739
-Ref: Egrep Program-Footnote-1702242
-Node: Id Program702352
-Node: Split Program706028
-Ref: Split Program-Footnote-1709482
-Node: Tee Program709610
-Node: Uniq Program712399
-Node: Wc Program719818
-Ref: Wc Program-Footnote-1724068
-Node: Miscellaneous Programs724162
-Node: Dupword Program725375
-Node: Alarm Program727406
-Node: Translate Program732211
-Ref: Translate Program-Footnote-1736774
-Node: Labels Program737044
-Ref: Labels Program-Footnote-1740395
-Node: Word Sorting740479
-Node: History Sorting744549
-Node: Extract Program746384
-Node: Simple Sed753908
-Node: Igawk Program756978
-Ref: Igawk Program-Footnote-1771304
-Ref: Igawk Program-Footnote-2771505
-Ref: Igawk Program-Footnote-3771627
-Node: Anagram Program771742
-Node: Signature Program774803
-Node: Programs Summary776050
-Node: Programs Exercises777271
-Ref: Programs Exercises-Footnote-1781402
-Node: Advanced Features781493
-Node: Nondecimal Data783475
-Node: Array Sorting785065
-Node: Controlling Array Traversal785765
-Ref: Controlling Array Traversal-Footnote-1794131
-Node: Array Sorting Functions794249
-Ref: Array Sorting Functions-Footnote-1798135
-Node: Two-way I/O798331
-Ref: Two-way I/O-Footnote-1803276
-Ref: Two-way I/O-Footnote-2803462
-Node: TCP/IP Networking803544
-Node: Profiling806416
-Node: Advanced Features Summary814687
-Node: Internationalization816620
-Node: I18N and L10N818100
-Node: Explaining gettext818786
-Ref: Explaining gettext-Footnote-1823811
-Ref: Explaining gettext-Footnote-2823995
-Node: Programmer i18n824160
-Ref: Programmer i18n-Footnote-1829036
-Node: Translator i18n829085
-Node: String Extraction829879
-Ref: String Extraction-Footnote-1831010
-Node: Printf Ordering831096
-Ref: Printf Ordering-Footnote-1833882
-Node: I18N Portability833946
-Ref: I18N Portability-Footnote-1836402
-Node: I18N Example836465
-Ref: I18N Example-Footnote-1839268
-Node: Gawk I18N839340
-Node: I18N Summary839984
-Node: Debugger841324
-Node: Debugging842346
-Node: Debugging Concepts842787
-Node: Debugging Terms844597
-Node: Awk Debugging847169
-Node: Sample Debugging Session848075
-Node: Debugger Invocation848609
-Node: Finding The Bug849994
-Node: List of Debugger Commands856473
-Node: Breakpoint Control857805
-Node: Debugger Execution Control861482
-Node: Viewing And Changing Data864841
-Node: Execution Stack868217
-Node: Debugger Info869852
-Node: Miscellaneous Debugger Commands873897
-Node: Readline Support878898
-Node: Limitations879792
-Node: Debugging Summary881907
-Node: Arbitrary Precision Arithmetic883081
-Node: Computer Arithmetic884497
-Ref: table-numeric-ranges888074
-Ref: Computer Arithmetic-Footnote-1888598
-Node: Math Definitions888655
-Ref: table-ieee-formats891950
-Ref: Math Definitions-Footnote-1892554
-Node: MPFR features892659
-Node: FP Math Caution894330
-Ref: FP Math Caution-Footnote-1895380
-Node: Inexactness of computations895749
-Node: Inexact representation896708
-Node: Comparing FP Values898066
-Node: Errors accumulate899148
-Node: Getting Accuracy900580
-Node: Try To Round903284
-Node: Setting precision904183
-Ref: table-predefined-precision-strings904867
-Node: Setting the rounding mode906696
-Ref: table-gawk-rounding-modes907060
-Ref: Setting the rounding mode-Footnote-1910512
-Node: Arbitrary Precision Integers910691
-Ref: Arbitrary Precision Integers-Footnote-1915589
-Node: POSIX Floating Point Problems915738
-Ref: POSIX Floating Point Problems-Footnote-1919617
-Node: Floating point summary919655
-Node: Dynamic Extensions921842
-Node: Extension Intro923394
-Node: Plugin License924659
-Node: Extension Mechanism Outline925456
-Ref: figure-load-extension925884
-Ref: figure-register-new-function927364
-Ref: figure-call-new-function928368
-Node: Extension API Description930355
-Node: Extension API Functions Introduction931889
-Node: General Data Types936758
-Ref: General Data Types-Footnote-1942658
-Node: Memory Allocation Functions942957
-Ref: Memory Allocation Functions-Footnote-1945796
-Node: Constructor Functions945895
-Node: Registration Functions947634
-Node: Extension Functions948319
-Node: Exit Callback Functions950616
-Node: Extension Version String951864
-Node: Input Parsers952527
-Node: Output Wrappers962402
-Node: Two-way processors966915
-Node: Printing Messages969178
-Ref: Printing Messages-Footnote-1970254
-Node: Updating `ERRNO'970406
-Node: Requesting Values971146
-Ref: table-value-types-returned971873
-Node: Accessing Parameters972830
-Node: Symbol Table Access974064
-Node: Symbol table by name974578
-Node: Symbol table by cookie976598
-Ref: Symbol table by cookie-Footnote-1980743
-Node: Cached values980806
-Ref: Cached values-Footnote-1984302
-Node: Array Manipulation984393
-Ref: Array Manipulation-Footnote-1985483
-Node: Array Data Types985520
-Ref: Array Data Types-Footnote-1988175
-Node: Array Functions988267
-Node: Flattening Arrays992126
-Node: Creating Arrays999028
-Node: Redirection API1003799
-Node: Extension API Variables1006624
-Node: Extension Versioning1007257
-Node: Extension API Informational Variables1009148
-Node: Extension API Boilerplate1010213
-Node: Finding Extensions1014022
-Node: Extension Example1014582
-Node: Internal File Description1015354
-Node: Internal File Ops1019421
-Ref: Internal File Ops-Footnote-11031172
-Node: Using Internal File Ops1031312
-Ref: Using Internal File Ops-Footnote-11033695
-Node: Extension Samples1033968
-Node: Extension Sample File Functions1035496
-Node: Extension Sample Fnmatch1043177
-Node: Extension Sample Fork1044665
-Node: Extension Sample Inplace1045880
-Node: Extension Sample Ord1047966
-Node: Extension Sample Readdir1048802
-Ref: table-readdir-file-types1049679
-Node: Extension Sample Revout1050490
-Node: Extension Sample Rev2way1051079
-Node: Extension Sample Read write array1051819
-Node: Extension Sample Readfile1053759
-Node: Extension Sample Time1054854
-Node: Extension Sample API Tests1056202
-Node: gawkextlib1056693
-Node: Extension summary1059371
-Node: Extension Exercises1063060
-Node: Language History1064556
-Node: V7/SVR3.11066212
-Node: SVR41068365
-Node: POSIX1069799
-Node: BTL1071180
-Node: POSIX/GNU1071911
-Node: Feature History1077747
-Node: Common Extensions1091541
-Node: Ranges and Locales1092913
-Ref: Ranges and Locales-Footnote-11097532
-Ref: Ranges and Locales-Footnote-21097559
-Ref: Ranges and Locales-Footnote-31097794
-Node: Contributors1098015
-Node: History summary1103555
-Node: Installation1104934
-Node: Gawk Distribution1105880
-Node: Getting1106364
-Node: Extracting1107187
-Node: Distribution contents1108824
-Node: Unix Installation1114926
-Node: Quick Installation1115609
-Node: Shell Startup Files1118020
-Node: Additional Configuration Options1119099
-Node: Configuration Philosophy1120903
-Node: Non-Unix Installation1123272
-Node: PC Installation1123730
-Node: PC Binary Installation1125050
-Node: PC Compiling1126898
-Ref: PC Compiling-Footnote-11129919
-Node: PC Testing1130028
-Node: PC Using1131204
-Node: Cygwin1135319
-Node: MSYS1136089
-Node: VMS Installation1136590
-Node: VMS Compilation1137382
-Ref: VMS Compilation-Footnote-11138611
-Node: VMS Dynamic Extensions1138669
-Node: VMS Installation Details1140353
-Node: VMS Running1142604
-Node: VMS GNV1145444
-Node: VMS Old Gawk1146179
-Node: Bugs1146649
-Node: Other Versions1150538
-Node: Installation summary1156972
-Node: Notes1158031
-Node: Compatibility Mode1158896
-Node: Additions1159678
-Node: Accessing The Source1160603
-Node: Adding Code1162038
-Node: New Ports1168195
-Node: Derived Files1172677
-Ref: Derived Files-Footnote-11178152
-Ref: Derived Files-Footnote-21178186
-Ref: Derived Files-Footnote-31178782
-Node: Future Extensions1178896
-Node: Implementation Limitations1179502
-Node: Extension Design1180750
-Node: Old Extension Problems1181904
-Ref: Old Extension Problems-Footnote-11183421
-Node: Extension New Mechanism Goals1183478
-Ref: Extension New Mechanism Goals-Footnote-11186838
-Node: Extension Other Design Decisions1187027
-Node: Extension Future Growth1189135
-Node: Old Extension Mechanism1189971
-Node: Notes summary1191733
-Node: Basic Concepts1192919
-Node: Basic High Level1193600
-Ref: figure-general-flow1193872
-Ref: figure-process-flow1194471
-Ref: Basic High Level-Footnote-11197700
-Node: Basic Data Typing1197885
-Node: Glossary1201213
-Node: Copying1233142
-Node: GNU Free Documentation License1270698
-Node: Index1295834
+Node: Command-line directories267251
+Node: Input Summary268158
+Node: Input Exercises271543
+Node: Printing272271
+Node: Print274106
+Node: Print Examples275563
+Node: Output Separators278342
+Node: OFMT280360
+Node: Printf281715
+Node: Basic Printf282500
+Node: Control Letters284072
+Node: Format Modifiers288057
+Node: Printf Examples294063
+Node: Redirection296549
+Node: Special FD303387
+Ref: Special FD-Footnote-1306553
+Node: Special Files306627
+Node: Other Inherited Files307244
+Node: Special Network308244
+Node: Special Caveats309106
+Node: Close Files And Pipes310055
+Ref: Close Files And Pipes-Footnote-1317240
+Ref: Close Files And Pipes-Footnote-2317388
+Node: Nonfatal317538
+Node: Output Summary319863
+Node: Output Exercises321084
+Node: Expressions321764
+Node: Values322953
+Node: Constants323630
+Node: Scalar Constants324321
+Ref: Scalar Constants-Footnote-1325183
+Node: Nondecimal-numbers325433
+Node: Regexp Constants328443
+Node: Using Constant Regexps328969
+Node: Variables332132
+Node: Using Variables332789
+Node: Assignment Options334700
+Node: Conversion336575
+Node: Strings And Numbers337099
+Ref: Strings And Numbers-Footnote-1340164
+Node: Locale influences conversions340273
+Ref: table-locale-affects343019
+Node: All Operators343611
+Node: Arithmetic Ops344240
+Node: Concatenation346745
+Ref: Concatenation-Footnote-1349564
+Node: Assignment Ops349671
+Ref: table-assign-ops354650
+Node: Increment Ops355960
+Node: Truth Values and Conditions359391
+Node: Truth Values360474
+Node: Typing and Comparison361523
+Node: Variable Typing362339
+Node: Comparison Operators366006
+Ref: table-relational-ops366416
+Node: POSIX String Comparison369911
+Ref: POSIX String Comparison-Footnote-1370983
+Node: Boolean Ops371122
+Ref: Boolean Ops-Footnote-1375600
+Node: Conditional Exp375691
+Node: Function Calls377429
+Node: Precedence381309
+Node: Locales384969
+Node: Expressions Summary386601
+Node: Patterns and Actions389172
+Node: Pattern Overview390292
+Node: Regexp Patterns391971
+Node: Expression Patterns392514
+Node: Ranges396294
+Node: BEGIN/END399401
+Node: Using BEGIN/END400162
+Ref: Using BEGIN/END-Footnote-1402898
+Node: I/O And BEGIN/END403004
+Node: BEGINFILE/ENDFILE405319
+Node: Empty408216
+Node: Using Shell Variables408533
+Node: Action Overview410806
+Node: Statements413132
+Node: If Statement414980
+Node: While Statement416475
+Node: Do Statement418503
+Node: For Statement419651
+Node: Switch Statement422809
+Node: Break Statement425191
+Node: Continue Statement427284
+Node: Next Statement429111
+Node: Nextfile Statement431492
+Node: Exit Statement434120
+Node: Built-in Variables436531
+Node: User-modified437664
+Ref: User-modified-Footnote-1445298
+Node: Auto-set445360
+Ref: Auto-set-Footnote-1459593
+Ref: Auto-set-Footnote-2459798
+Node: ARGC and ARGV459854
+Node: Pattern Action Summary464072
+Node: Arrays466505
+Node: Array Basics467834
+Node: Array Intro468678
+Ref: figure-array-elements470615
+Ref: Array Intro-Footnote-1473238
+Node: Reference to Elements473366
+Node: Assigning Elements475828
+Node: Array Example476319
+Node: Scanning an Array478078
+Node: Controlling Scanning481101
+Ref: Controlling Scanning-Footnote-1486495
+Node: Numeric Array Subscripts486811
+Node: Uninitialized Subscripts488996
+Node: Delete490613
+Ref: Delete-Footnote-1493362
+Node: Multidimensional493419
+Node: Multiscanning496516
+Node: Arrays of Arrays498105
+Node: Arrays Summary502859
+Node: Functions504950
+Node: Built-in505989
+Node: Calling Built-in507067
+Node: Numeric Functions509062
+Ref: Numeric Functions-Footnote-1513895
+Ref: Numeric Functions-Footnote-2514252
+Ref: Numeric Functions-Footnote-3514300
+Node: String Functions514572
+Ref: String Functions-Footnote-1538073
+Ref: String Functions-Footnote-2538202
+Ref: String Functions-Footnote-3538450
+Node: Gory Details538537
+Ref: table-sub-escapes540318
+Ref: table-sub-proposed541833
+Ref: table-posix-sub543195
+Ref: table-gensub-escapes544732
+Ref: Gory Details-Footnote-1545565
+Node: I/O Functions545716
+Ref: I/O Functions-Footnote-1552952
+Node: Time Functions553099
+Ref: Time Functions-Footnote-1563608
+Ref: Time Functions-Footnote-2563676
+Ref: Time Functions-Footnote-3563834
+Ref: Time Functions-Footnote-4563945
+Ref: Time Functions-Footnote-5564057
+Ref: Time Functions-Footnote-6564284
+Node: Bitwise Functions564550
+Ref: table-bitwise-ops565112
+Ref: Bitwise Functions-Footnote-1569440
+Node: Type Functions569612
+Node: I18N Functions570764
+Node: User-defined572411
+Node: Definition Syntax573216
+Ref: Definition Syntax-Footnote-1578875
+Node: Function Example578946
+Ref: Function Example-Footnote-1581867
+Node: Function Caveats581889
+Node: Calling A Function582407
+Node: Variable Scope583365
+Node: Pass By Value/Reference586358
+Node: Return Statement589855
+Node: Dynamic Typing592834
+Node: Indirect Calls593763
+Ref: Indirect Calls-Footnote-1604006
+Node: Functions Summary604134
+Node: Library Functions606836
+Ref: Library Functions-Footnote-1610444
+Ref: Library Functions-Footnote-2610587
+Node: Library Names610758
+Ref: Library Names-Footnote-1614216
+Ref: Library Names-Footnote-2614439
+Node: General Functions614525
+Node: Strtonum Function615628
+Node: Assert Function618650
+Node: Round Function621974
+Node: Cliff Random Function623515
+Node: Ordinal Functions624531
+Ref: Ordinal Functions-Footnote-1627594
+Ref: Ordinal Functions-Footnote-2627846
+Node: Join Function628057
+Ref: Join Function-Footnote-1629827
+Node: Getlocaltime Function630027
+Node: Readfile Function633771
+Node: Shell Quoting635743
+Node: Data File Management637144
+Node: Filetrans Function637776
+Node: Rewind Function641872
+Node: File Checking643258
+Ref: File Checking-Footnote-1644591
+Node: Empty Files644792
+Node: Ignoring Assigns646771
+Node: Getopt Function648321
+Ref: Getopt Function-Footnote-1659785
+Node: Passwd Functions659985
+Ref: Passwd Functions-Footnote-1668825
+Node: Group Functions668913
+Ref: Group Functions-Footnote-1676810
+Node: Walking Arrays677015
+Node: Library Functions Summary680021
+Node: Library Exercises681423
+Node: Sample Programs682703
+Node: Running Examples683473
+Node: Clones684201
+Node: Cut Program685425
+Node: Egrep Program695145
+Ref: Egrep Program-Footnote-1702648
+Node: Id Program702758
+Node: Split Program706434
+Ref: Split Program-Footnote-1709888
+Node: Tee Program710016
+Node: Uniq Program712805
+Node: Wc Program720224
+Ref: Wc Program-Footnote-1724474
+Node: Miscellaneous Programs724568
+Node: Dupword Program725781
+Node: Alarm Program727812
+Node: Translate Program732617
+Ref: Translate Program-Footnote-1737180
+Node: Labels Program737450
+Ref: Labels Program-Footnote-1740801
+Node: Word Sorting740885
+Node: History Sorting744955
+Node: Extract Program746790
+Node: Simple Sed754314
+Node: Igawk Program757384
+Ref: Igawk Program-Footnote-1771710
+Ref: Igawk Program-Footnote-2771911
+Ref: Igawk Program-Footnote-3772033
+Node: Anagram Program772148
+Node: Signature Program775209
+Node: Programs Summary776456
+Node: Programs Exercises777677
+Ref: Programs Exercises-Footnote-1781808
+Node: Advanced Features781899
+Node: Nondecimal Data783881
+Node: Array Sorting785471
+Node: Controlling Array Traversal786171
+Ref: Controlling Array Traversal-Footnote-1794537
+Node: Array Sorting Functions794655
+Ref: Array Sorting Functions-Footnote-1798541
+Node: Two-way I/O798737
+Ref: Two-way I/O-Footnote-1803682
+Ref: Two-way I/O-Footnote-2803868
+Node: TCP/IP Networking803950
+Node: Profiling806822
+Node: Advanced Features Summary815093
+Node: Internationalization817026
+Node: I18N and L10N818506
+Node: Explaining gettext819192
+Ref: Explaining gettext-Footnote-1824217
+Ref: Explaining gettext-Footnote-2824401
+Node: Programmer i18n824566
+Ref: Programmer i18n-Footnote-1829442
+Node: Translator i18n829491
+Node: String Extraction830285
+Ref: String Extraction-Footnote-1831416
+Node: Printf Ordering831502
+Ref: Printf Ordering-Footnote-1834288
+Node: I18N Portability834352
+Ref: I18N Portability-Footnote-1836808
+Node: I18N Example836871
+Ref: I18N Example-Footnote-1839674
+Node: Gawk I18N839746
+Node: I18N Summary840390
+Node: Debugger841730
+Node: Debugging842752
+Node: Debugging Concepts843193
+Node: Debugging Terms845003
+Node: Awk Debugging847575
+Node: Sample Debugging Session848481
+Node: Debugger Invocation849015
+Node: Finding The Bug850400
+Node: List of Debugger Commands856879
+Node: Breakpoint Control858211
+Node: Debugger Execution Control861888
+Node: Viewing And Changing Data865247
+Node: Execution Stack868623
+Node: Debugger Info870258
+Node: Miscellaneous Debugger Commands874303
+Node: Readline Support879304
+Node: Limitations880198
+Node: Debugging Summary882313
+Node: Arbitrary Precision Arithmetic883487
+Node: Computer Arithmetic884903
+Ref: table-numeric-ranges888480
+Ref: Computer Arithmetic-Footnote-1889004
+Node: Math Definitions889061
+Ref: table-ieee-formats892356
+Ref: Math Definitions-Footnote-1892960
+Node: MPFR features893065
+Node: FP Math Caution894736
+Ref: FP Math Caution-Footnote-1895786
+Node: Inexactness of computations896155
+Node: Inexact representation897114
+Node: Comparing FP Values898472
+Node: Errors accumulate899554
+Node: Getting Accuracy900986
+Node: Try To Round903690
+Node: Setting precision904589
+Ref: table-predefined-precision-strings905273
+Node: Setting the rounding mode907102
+Ref: table-gawk-rounding-modes907466
+Ref: Setting the rounding mode-Footnote-1910918
+Node: Arbitrary Precision Integers911097
+Ref: Arbitrary Precision Integers-Footnote-1916013
+Node: POSIX Floating Point Problems916162
+Ref: POSIX Floating Point Problems-Footnote-1920041
+Node: Floating point summary920079
+Node: Dynamic Extensions922266
+Node: Extension Intro923818
+Node: Plugin License925083
+Node: Extension Mechanism Outline925880
+Ref: figure-load-extension926308
+Ref: figure-register-new-function927788
+Ref: figure-call-new-function928792
+Node: Extension API Description930779
+Node: Extension API Functions Introduction932313
+Node: General Data Types937182
+Ref: General Data Types-Footnote-1943082
+Node: Memory Allocation Functions943381
+Ref: Memory Allocation Functions-Footnote-1946220
+Node: Constructor Functions946319
+Node: Registration Functions948058
+Node: Extension Functions948743
+Node: Exit Callback Functions951040
+Node: Extension Version String952288
+Node: Input Parsers952951
+Node: Output Wrappers962826
+Node: Two-way processors967339
+Node: Printing Messages969602
+Ref: Printing Messages-Footnote-1970678
+Node: Updating `ERRNO'970830
+Node: Requesting Values971570
+Ref: table-value-types-returned972297
+Node: Accessing Parameters973254
+Node: Symbol Table Access974488
+Node: Symbol table by name975002
+Node: Symbol table by cookie977022
+Ref: Symbol table by cookie-Footnote-1981167
+Node: Cached values981230
+Ref: Cached values-Footnote-1984726
+Node: Array Manipulation984817
+Ref: Array Manipulation-Footnote-1985907
+Node: Array Data Types985944
+Ref: Array Data Types-Footnote-1988599
+Node: Array Functions988691
+Node: Flattening Arrays992550
+Node: Creating Arrays999452
+Node: Redirection API1004223
+Node: Extension API Variables1007048
+Node: Extension Versioning1007681
+Node: Extension API Informational Variables1009572
+Node: Extension API Boilerplate1010637
+Node: Finding Extensions1014446
+Node: Extension Example1015006
+Node: Internal File Description1015778
+Node: Internal File Ops1019845
+Ref: Internal File Ops-Footnote-11031596
+Node: Using Internal File Ops1031736
+Ref: Using Internal File Ops-Footnote-11034119
+Node: Extension Samples1034392
+Node: Extension Sample File Functions1035920
+Node: Extension Sample Fnmatch1043601
+Node: Extension Sample Fork1045089
+Node: Extension Sample Inplace1046304
+Node: Extension Sample Ord1048390
+Node: Extension Sample Readdir1049226
+Ref: table-readdir-file-types1050103
+Node: Extension Sample Revout1050914
+Node: Extension Sample Rev2way1051503
+Node: Extension Sample Read write array1052243
+Node: Extension Sample Readfile1054183
+Node: Extension Sample Time1055278
+Node: Extension Sample API Tests1056626
+Node: gawkextlib1057117
+Node: Extension summary1059818
+Node: Extension Exercises1063507
+Node: Language History1065003
+Node: V7/SVR3.11066659
+Node: SVR41068812
+Node: POSIX1070246
+Node: BTL1071627
+Node: POSIX/GNU1072358
+Node: Feature History1078197
+Node: Common Extensions1091994
+Node: Ranges and Locales1093366
+Ref: Ranges and Locales-Footnote-11097985
+Ref: Ranges and Locales-Footnote-21098012
+Ref: Ranges and Locales-Footnote-31098247
+Node: Contributors1098468
+Node: History summary1104008
+Node: Installation1105387
+Node: Gawk Distribution1106333
+Node: Getting1106817
+Node: Extracting1107640
+Node: Distribution contents1109277
+Node: Unix Installation1115379
+Node: Quick Installation1116062
+Node: Shell Startup Files1118473
+Node: Additional Configuration Options1119552
+Node: Configuration Philosophy1121356
+Node: Non-Unix Installation1123725
+Node: PC Installation1124183
+Node: PC Binary Installation1125503
+Node: PC Compiling1127351
+Ref: PC Compiling-Footnote-11130372
+Node: PC Testing1130481
+Node: PC Using1131657
+Node: Cygwin1135772
+Node: MSYS1136542
+Node: VMS Installation1137043
+Node: VMS Compilation1137835
+Ref: VMS Compilation-Footnote-11139064
+Node: VMS Dynamic Extensions1139122
+Node: VMS Installation Details1140806
+Node: VMS Running1143057
+Node: VMS GNV1145897
+Node: VMS Old Gawk1146632
+Node: Bugs1147102
+Node: Other Versions1150991
+Node: Installation summary1157425
+Node: Notes1158484
+Node: Compatibility Mode1159349
+Node: Additions1160131
+Node: Accessing The Source1161056
+Node: Adding Code1162491
+Node: New Ports1168648
+Node: Derived Files1173130
+Ref: Derived Files-Footnote-11178605
+Ref: Derived Files-Footnote-21178639
+Ref: Derived Files-Footnote-31179235
+Node: Future Extensions1179349
+Node: Implementation Limitations1179955
+Node: Extension Design1181203
+Node: Old Extension Problems1182357
+Ref: Old Extension Problems-Footnote-11183874
+Node: Extension New Mechanism Goals1183931
+Ref: Extension New Mechanism Goals-Footnote-11187291
+Node: Extension Other Design Decisions1187480
+Node: Extension Future Growth1189588
+Node: Old Extension Mechanism1190424
+Node: Notes summary1192186
+Node: Basic Concepts1193372
+Node: Basic High Level1194053
+Ref: figure-general-flow1194325
+Ref: figure-process-flow1194924
+Ref: Basic High Level-Footnote-11198153
+Node: Basic Data Typing1198338
+Node: Glossary1201666
+Node: Copying1233595
+Node: GNU Free Documentation License1271151
+Node: Index1296287

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index e9d987f0..ca378cca 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -8807,6 +8807,7 @@ PROCINFO["@var{input_name}", "RETRY"] = 1
@end example
When this element exists, @command{gawk} checks the value of the system
+(C language)
@code{errno} variable when an I/O error occurs. If @code{errno} indicates
a subsequent I/O attempt may succeed, @code{getline} instead returns
@minus{}2 and
@@ -17088,23 +17089,6 @@ You can use @samp{pi = atan2(0, -1)} to retrieve the value of
@cindex cosine
Return the cosine of @var{x}, with @var{x} in radians.
-@item @code{div(@var{numerator}, @var{denominator}, @var{result})}
-@cindexawkfunc{div}
-@cindex div
-Perform integer division, similar to the standard C function of the
-same name. First, truncate @code{numerator} and @code{denominator}
-towards zero, creating integer values. Clear the @code{result}
-array, and then set @code{result["quotient"]} to the result of
-@samp{numerator / denominator}, truncated towards zero to an integer,
-and set @code{result["remainder"]} to the result of @samp{numerator %
-denominator}, truncated towards zero to an integer. This function is
-primarily intended for use with arbitrary length integers; it avoids
-creating MPFR arbitrary precision floating-point values (@pxref{Arbitrary
-Precision Integers}).
-
-This function is a @code{gawk} extension. It is not available in
-compatibility mode (@pxref{Options}).
-
@item @code{exp(@var{x})}
@cindexawkfunc{exp}
@cindex exponent
@@ -17120,6 +17104,23 @@ truncated toward zero.
For example, @code{int(3)} is 3, @code{int(3.9)} is 3, @code{int(-3.9)}
is @minus{}3, and @code{int(-3)} is @minus{}3 as well.
+@item @code{intdiv(@var{numerator}, @var{denominator}, @var{result})}
+@cindexawkfunc{intdiv}
+@cindex intdiv
+Perform integer division, similar to the standard C function of the
+same name. First, truncate @code{numerator} and @code{denominator}
+towards zero, creating integer values. Clear the @code{result}
+array, and then set @code{result["quotient"]} to the result of
+@samp{numerator / denominator}, truncated towards zero to an integer,
+and set @code{result["remainder"]} to the result of @samp{numerator %
+denominator}, truncated towards zero to an integer. This function is
+primarily intended for use with arbitrary length integers; it avoids
+creating MPFR arbitrary precision floating-point values (@pxref{Arbitrary
+Precision Integers}).
+
+This function is a @code{gawk} extension. It is not available in
+compatibility mode (@pxref{Options}).
+
@item @code{log(@var{x})}
@cindexawkfunc{log}
@cindex logarithm
@@ -17152,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
@@ -20505,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:
@@ -31100,27 +31114,30 @@ When dividing two arbitrary precision integers with either
precision floating point value (unless the denominator evenly
divides into the numerator). In order to do integer division
or remainder with arbitrary precision integers, use the built-in
-@code{div()} function (@pxref{Numeric Functions}).
+@code{intdiv()} function (@pxref{Numeric Functions}).
-You can simulate the @code{div()} function in standard @command{awk}
+You can simulate the @code{intdiv()} function in standard @command{awk}
using this user-defined function:
@example
-@c file eg/lib/div.awk
-# div --- do integer division
+@c file eg/lib/intdiv.awk
+# intdiv --- do integer division
@c endfile
@ignore
-@c file eg/lib/div.awk
+@c file eg/lib/intdiv.awk
#
# Arnold Robbins, arnold@@skeeve.com, Public Domain
# July, 2014
+#
+# Name changed from div() to intdiv()
+# April, 2015
@c endfile
@end ignore
-@c file eg/lib/div.awk
-function div(numerator, denominator, result)
+@c file eg/lib/intdiv.awk
+function intdiv(numerator, denominator, result)
@{
split("", result)
@@ -31135,7 +31152,7 @@ function div(numerator, denominator, result)
@end example
The following example program, contributed by Katie Wasserman,
-uses @code{div()} to
+uses @code{intdiv()} to
compute the digits of @value{PI} to as many places as you
choose to set:
@@ -31160,7 +31177,7 @@ BEGIN @{
for (m = digits * 4; m > 0; --m) @{
d = m * 2 + 1
x = pi * m
- div(x, d, result)
+ intdiv(x, d, result)
pi = result["quotient"]
pi = pi + two
@}
@@ -35285,18 +35302,21 @@ As of this writing, there are seven extensions:
GD graphics library extension
@item
+MPFR library extension
+(this provides access to a number of MPFR functions that @command{gawk}'s
+native MPFR support does not)
+
+@item
PDF extension
@item
PostgreSQL extension
@item
-MPFR library extension
-(this provides access to a number of MPFR functions that @command{gawk}'s
-native MPFR support does not)
+Redis extension
@item
-Redis extension
+Select extension
@item
XML parser extension, using the @uref{http://expat.sourceforge.net, Expat}
@@ -36026,7 +36046,7 @@ functions for internationalization
(@pxref{Programmer i18n})
@item
-The @code{div()} function for doing integer
+The @code{intdiv()} function for doing integer
division and remainder
(@pxref{Numeric Functions})
@end itemize
@@ -36807,7 +36827,7 @@ installed when @command{gawk} is built.
@xref{Igawk Program}.
@item
-The @code{div()} function.
+The @code{intdiv()} function.
@xref{Numeric Functions}.
@item
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index 178444a4..4cd04763 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -8407,6 +8407,7 @@ PROCINFO["@var{input_name}", "RETRY"] = 1
@end example
When this element exists, @command{gawk} checks the value of the system
+(C language)
@code{errno} variable when an I/O error occurs. If @code{errno} indicates
a subsequent I/O attempt may succeed, @code{getline} instead returns
@minus{}2 and
@@ -16370,23 +16371,6 @@ You can use @samp{pi = atan2(0, -1)} to retrieve the value of
@cindex cosine
Return the cosine of @var{x}, with @var{x} in radians.
-@item @code{div(@var{numerator}, @var{denominator}, @var{result})}
-@cindexawkfunc{div}
-@cindex div
-Perform integer division, similar to the standard C function of the
-same name. First, truncate @code{numerator} and @code{denominator}
-towards zero, creating integer values. Clear the @code{result}
-array, and then set @code{result["quotient"]} to the result of
-@samp{numerator / denominator}, truncated towards zero to an integer,
-and set @code{result["remainder"]} to the result of @samp{numerator %
-denominator}, truncated towards zero to an integer. This function is
-primarily intended for use with arbitrary length integers; it avoids
-creating MPFR arbitrary precision floating-point values (@pxref{Arbitrary
-Precision Integers}).
-
-This function is a @code{gawk} extension. It is not available in
-compatibility mode (@pxref{Options}).
-
@item @code{exp(@var{x})}
@cindexawkfunc{exp}
@cindex exponent
@@ -16402,6 +16386,23 @@ truncated toward zero.
For example, @code{int(3)} is 3, @code{int(3.9)} is 3, @code{int(-3.9)}
is @minus{}3, and @code{int(-3)} is @minus{}3 as well.
+@item @code{intdiv(@var{numerator}, @var{denominator}, @var{result})}
+@cindexawkfunc{intdiv}
+@cindex intdiv
+Perform integer division, similar to the standard C function of the
+same name. First, truncate @code{numerator} and @code{denominator}
+towards zero, creating integer values. Clear the @code{result}
+array, and then set @code{result["quotient"]} to the result of
+@samp{numerator / denominator}, truncated towards zero to an integer,
+and set @code{result["remainder"]} to the result of @samp{numerator %
+denominator}, truncated towards zero to an integer. This function is
+primarily intended for use with arbitrary length integers; it avoids
+creating MPFR arbitrary precision floating-point values (@pxref{Arbitrary
+Precision Integers}).
+
+This function is a @code{gawk} extension. It is not available in
+compatibility mode (@pxref{Options}).
+
@item @code{log(@var{x})}
@cindexawkfunc{log}
@cindex logarithm
@@ -16434,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
@@ -19626,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:
@@ -30191,27 +30205,30 @@ When dividing two arbitrary precision integers with either
precision floating point value (unless the denominator evenly
divides into the numerator). In order to do integer division
or remainder with arbitrary precision integers, use the built-in
-@code{div()} function (@pxref{Numeric Functions}).
+@code{intdiv()} function (@pxref{Numeric Functions}).
-You can simulate the @code{div()} function in standard @command{awk}
+You can simulate the @code{intdiv()} function in standard @command{awk}
using this user-defined function:
@example
-@c file eg/lib/div.awk
-# div --- do integer division
+@c file eg/lib/intdiv.awk
+# intdiv --- do integer division
@c endfile
@ignore
-@c file eg/lib/div.awk
+@c file eg/lib/intdiv.awk
#
# Arnold Robbins, arnold@@skeeve.com, Public Domain
# July, 2014
+#
+# Name changed from div() to intdiv()
+# April, 2015
@c endfile
@end ignore
-@c file eg/lib/div.awk
-function div(numerator, denominator, result)
+@c file eg/lib/intdiv.awk
+function intdiv(numerator, denominator, result)
@{
split("", result)
@@ -30226,7 +30243,7 @@ function div(numerator, denominator, result)
@end example
The following example program, contributed by Katie Wasserman,
-uses @code{div()} to
+uses @code{intdiv()} to
compute the digits of @value{PI} to as many places as you
choose to set:
@@ -30251,7 +30268,7 @@ BEGIN @{
for (m = digits * 4; m > 0; --m) @{
d = m * 2 + 1
x = pi * m
- div(x, d, result)
+ intdiv(x, d, result)
pi = result["quotient"]
pi = pi + two
@}
@@ -34376,18 +34393,21 @@ As of this writing, there are seven extensions:
GD graphics library extension
@item
+MPFR library extension
+(this provides access to a number of MPFR functions that @command{gawk}'s
+native MPFR support does not)
+
+@item
PDF extension
@item
PostgreSQL extension
@item
-MPFR library extension
-(this provides access to a number of MPFR functions that @command{gawk}'s
-native MPFR support does not)
+Redis extension
@item
-Redis extension
+Select extension
@item
XML parser extension, using the @uref{http://expat.sourceforge.net, Expat}
@@ -35117,7 +35137,7 @@ functions for internationalization
(@pxref{Programmer i18n})
@item
-The @code{div()} function for doing integer
+The @code{intdiv()} function for doing integer
division and remainder
(@pxref{Numeric Functions})
@end itemize
@@ -35898,7 +35918,7 @@ installed when @command{gawk} is built.
@xref{Igawk Program}.
@item
-The @code{div()} function.
+The @code{intdiv()} function.
@xref{Numeric Functions}.
@item
diff --git a/eval.c b/eval.c
index 8ee17615..18df2d01 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 cf158ca6..7b9079c0 100644
--- a/interpret.h
+++ b/interpret.h
@@ -1067,7 +1067,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/mpfr.c b/mpfr.c
index 571b334b..080ed7fa 100644
--- a/mpfr.c
+++ b/mpfr.c
@@ -1186,7 +1186,7 @@ do_mpfr_srand(int nargs)
return res;
}
-/* do_mpfr_div --- do integer division, return quotient and remainder in dest array */
+/* do_mpfr_intdiv --- do integer division, return quotient and remainder in dest array */
/*
* We define the semantics as:
@@ -1197,7 +1197,7 @@ do_mpfr_srand(int nargs)
*/
NODE *
-do_mpfr_div(int nargs)
+do_mpfr_intdiv(int nargs)
{
NODE *numerator, *denominator, *result;
NODE *num, *denom;
@@ -1206,7 +1206,7 @@ do_mpfr_div(int nargs)
result = POP_PARAM();
if (result->type != Node_var_array)
- fatal(_("div: third argument is not an array"));
+ fatal(_("intdiv: third argument is not an array"));
assoc_clear(result);
denominator = POP_SCALAR();
@@ -1214,9 +1214,9 @@ do_mpfr_div(int nargs)
if (do_lint) {
if ((numerator->flags & (NUMCUR|NUMBER)) == 0)
- lintwarn(_("div: received non-numeric first argument"));
+ lintwarn(_("intdiv: received non-numeric first argument"));
if ((denominator->flags & (NUMCUR|NUMBER)) == 0)
- lintwarn(_("div: received non-numeric second argument"));
+ lintwarn(_("intdiv: received non-numeric second argument"));
}
(void) force_number(numerator);
@@ -1250,7 +1250,7 @@ do_mpfr_div(int nargs)
}
if (mpz_sgn(denom->mpg_i) == 0)
- fatal(_("div: division by zero attempted"));
+ fatal(_("intdiv: division by zero attempted"));
quotient = mpg_integer();
remainder = mpg_integer();
diff --git a/test/ChangeLog b/test/ChangeLog
index 8aedf6f2..f9e49945 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,12 @@
+2015-04-02 Arnold D. Robbins <arnold@skeeve.com>
+
+ * id.ok, mpfrsqrt.awk: Update after rename of div() --> intdiv().
+
+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 +14,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..bd26b473 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
@@ -23,7 +24,6 @@ cos -> builtin
TEXTDOMAIN -> scalar
ORS -> scalar
split -> builtin
-div -> builtin
RSTART -> scalar
compl -> builtin
bindtextdomain -> builtin
@@ -62,6 +62,7 @@ sub -> builtin
OFMT -> scalar
RLENGTH -> scalar
substr -> builtin
+intdiv -> builtin
FPAT -> scalar
RS -> scalar
xor -> builtin
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
diff --git a/test/mpfrsqrt.awk b/test/mpfrsqrt.awk
index 23a15c92..3fb1f5f8 100644
--- a/test/mpfrsqrt.awk
+++ b/test/mpfrsqrt.awk
@@ -14,7 +14,7 @@ a=11111111111111111111111111111111111111111111111111111111111
print sqrt(a^2)
#print sq_root(a^2)
-# ADR: Added for gawk-4.1-stable which doesn't have built-in div() function
+# ADR: Added for gawk-4.1-stable which doesn't have built-in intdiv() function
if (PROCINFO["version"] < "4.1.60")
print sq_root2(a^2)
else
@@ -27,9 +27,9 @@ function sq_root(x, temp,r,z)
z=0
while (abs(z-temp)>1)
{ z=temp
- div(x,temp,r)
+ intdiv(x,temp,r)
temp=r["quotient"] + temp
- div(temp,2,r)
+ intdiv(temp,2,r)
temp=r["quotient"]
}
return temp