aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog18
-rw-r--r--NEWS13
-rw-r--r--awk.h1
-rw-r--r--awkgram.c742
-rw-r--r--awkgram.y24
-rw-r--r--doc/ChangeLog5
-rw-r--r--doc/gawk.info634
-rw-r--r--doc/gawk.texi19
-rw-r--r--doc/gawktexi.in19
-rw-r--r--symbol.c55
-rw-r--r--test/ChangeLog8
-rw-r--r--test/Makefile.am9
-rw-r--r--test/Makefile.in24
-rw-r--r--test/Maketests15
-rw-r--r--test/callparam.awk6
-rw-r--r--test/callparam.ok2
-rwxr-xr-xtest/exit.sh2
-rw-r--r--test/indirectcall.awk8
-rw-r--r--test/paramasfunc1.awk9
-rw-r--r--test/paramasfunc1.ok3
-rw-r--r--test/paramasfunc2.awk10
-rw-r--r--test/paramasfunc2.ok3
22 files changed, 928 insertions, 701 deletions
diff --git a/ChangeLog b/ChangeLog
index f40dfa23..28793ce3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2015-01-30 Arnold D. Robbins <arnold@skeeve.com>
+
+ Don't allow function parameter names to be the same as function
+ names - required by POSIX. Bug first reported in comp.lang.awk.
+
+ In addition, don't allow use of a parameter as a function name
+ in a call (but it's ok in indirect calls).
+
+ * NEWS: Updated.
+ * awk.h (check_param_names): Add declaration.
+ * awkgram.y (at_seen): New variable. Communicates between
+ yylex() and the parser.
+ (FUNC_CALL production): Check at_seen and check that the identifier
+ is a function name.
+ (parse_program): Call check_param_names() and set errcount.
+ (yylex): Set at_seen after seeing an at-sign.
+ * symbol.c (check_param_names): New function.
+
2015-01-24 Arnold D. Robbins <arnold@skeeve.com>
Infrastructure updates.
diff --git a/NEWS b/NEWS
index 0e8b678a..bf1ea842 100644
--- a/NEWS
+++ b/NEWS
@@ -53,6 +53,7 @@ Changes from 4.1.1 to 4.1.2
- Chapter 15 on MPFR reworked.
- Summary sections added to all chapters.
- Exercises added in several chapters.
+ - Heavily proof-read and copyedited.
2. The debugger's "restart" command now works again.
@@ -65,9 +66,10 @@ Changes from 4.1.1 to 4.1.2
6. Built-in functions are now included in FUNCTAB.
-7. In non-English locales, it was accidentally possible to use "letters"
- beside those of the English alphabet in identifiers. This has
- been fixed. (isalpha and isalnum are NOT our friends.)
+7. POSIX and historical practice require the exclusive use of the English
+ alphabet in identifiers. In non-English locales, it was accidentally
+ possible to use "letters" beside those of the English alphabet. This
+ has been fixed. (isalpha and isalnum are NOT our friends.)
If you feel that you must have this misfeature, use `configure --help'
to see what option to use when configuring gawk to reenable it.
@@ -84,6 +86,11 @@ Changes from 4.1.1 to 4.1.2
10. Infrastructure upgrades: Automake 1.15, Gettext 0.19.4, Libtool 2.4.5,
Bison 3.0.4.
+11. POSIX requires that the names of function parameters not be the
+ same as any of the special built-in variables and also not conflict
+ with the names of any functions. Gawk has checked for the former
+ since 3.1.7. It now also checks for the latter.
+
XX. A number of bugs have been fixed. See the ChangeLog.
Changes from 4.1.0 to 4.1.1
diff --git a/awk.h b/awk.h
index 74cc3c21..7817d60f 100644
--- a/awk.h
+++ b/awk.h
@@ -1616,6 +1616,7 @@ extern void free_context(AWK_CONTEXT *ctxt, bool keep_globals);
extern NODE **variable_list();
extern NODE **function_list(bool sort);
extern void print_vars(NODE **table, Func_print print_func, FILE *fp);
+extern bool check_param_names(void);
/* floatcomp.c */
#ifdef HAVE_UINTMAX_T
diff --git a/awkgram.c b/awkgram.c
index 733776cb..2d071152 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -127,6 +127,7 @@ static int one_line_close(int fd);
static void split_comment(void);
static void check_comment(void);
+static bool at_seen = false;
static bool want_source = false;
static bool want_regexp = false; /* lexical scanning kludge */
static char *in_function; /* parsing kludge */
@@ -201,7 +202,7 @@ extern double fmod(double x, double y);
#define YYSTYPE INSTRUCTION *
-#line 205 "awkgram.c" /* yacc.c:339 */
+#line 206 "awkgram.c" /* yacc.c:339 */
# ifndef YY_NULLPTR
# if defined __cplusplus && 201103L <= __cplusplus
@@ -355,7 +356,7 @@ int yyparse (void);
/* Copy the second part of user declarations. */
-#line 359 "awkgram.c" /* yacc.c:358 */
+#line 360 "awkgram.c" /* yacc.c:358 */
#ifdef short
# undef short
@@ -657,25 +658,25 @@ static const yytype_uint8 yytranslate[] =
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 204, 204, 206, 211, 212, 216, 228, 233, 244,
- 250, 255, 263, 271, 273, 278, 286, 288, 294, 302,
- 312, 342, 356, 370, 378, 389, 401, 403, 405, 411,
- 416, 417, 421, 456, 455, 489, 491, 496, 502, 530,
- 535, 536, 540, 542, 544, 551, 641, 683, 725, 838,
- 845, 852, 862, 871, 880, 889, 900, 916, 915, 939,
- 951, 951, 1049, 1049, 1082, 1112, 1118, 1119, 1125, 1126,
- 1133, 1138, 1150, 1164, 1166, 1174, 1179, 1181, 1189, 1191,
- 1200, 1201, 1209, 1214, 1214, 1225, 1229, 1237, 1238, 1241,
- 1243, 1248, 1249, 1258, 1259, 1264, 1269, 1275, 1277, 1279,
- 1286, 1287, 1293, 1294, 1299, 1301, 1306, 1308, 1316, 1321,
- 1330, 1337, 1339, 1341, 1357, 1367, 1374, 1376, 1381, 1383,
- 1385, 1393, 1395, 1400, 1402, 1407, 1409, 1411, 1461, 1463,
- 1465, 1467, 1469, 1471, 1473, 1475, 1489, 1494, 1499, 1524,
- 1530, 1532, 1534, 1536, 1538, 1540, 1545, 1549, 1581, 1583,
- 1589, 1595, 1608, 1609, 1610, 1615, 1620, 1624, 1628, 1643,
- 1656, 1661, 1697, 1715, 1716, 1722, 1723, 1728, 1730, 1737,
- 1754, 1771, 1773, 1780, 1785, 1793, 1803, 1815, 1824, 1828,
- 1832, 1836, 1840, 1844, 1847, 1849, 1853, 1857, 1861
+ 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
@@ -1848,24 +1849,24 @@ yyreduce:
switch (yyn)
{
case 3:
-#line 207 "awkgram.y" /* yacc.c:1646 */
+#line 208 "awkgram.y" /* yacc.c:1646 */
{
rule = 0;
yyerrok;
}
-#line 1857 "awkgram.c" /* yacc.c:1646 */
+#line 1858 "awkgram.c" /* yacc.c:1646 */
break;
case 5:
-#line 213 "awkgram.y" /* yacc.c:1646 */
+#line 214 "awkgram.y" /* yacc.c:1646 */
{
next_sourcefile();
}
-#line 1865 "awkgram.c" /* yacc.c:1646 */
+#line 1866 "awkgram.c" /* yacc.c:1646 */
break;
case 6:
-#line 217 "awkgram.y" /* yacc.c:1646 */
+#line 218 "awkgram.y" /* yacc.c:1646 */
{
rule = 0;
/*
@@ -1874,20 +1875,20 @@ yyreduce:
*/
/* yyerrok; */
}
-#line 1878 "awkgram.c" /* yacc.c:1646 */
+#line 1879 "awkgram.c" /* yacc.c:1646 */
break;
case 7:
-#line 229 "awkgram.y" /* yacc.c:1646 */
+#line 230 "awkgram.y" /* yacc.c:1646 */
{
(void) append_rule((yyvsp[-1]), (yyvsp[0]));
first_rule = false;
}
-#line 1887 "awkgram.c" /* yacc.c:1646 */
+#line 1888 "awkgram.c" /* yacc.c:1646 */
break;
case 8:
-#line 234 "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]);
@@ -1898,39 +1899,41 @@ yyreduce:
} else /* pattern rule with non-empty pattern */
(void) append_rule((yyvsp[-1]), NULL);
}
-#line 1902 "awkgram.c" /* yacc.c:1646 */
+#line 1903 "awkgram.c" /* yacc.c:1646 */
break;
case 9:
-#line 245 "awkgram.y" /* yacc.c:1646 */
+#line 246 "awkgram.y" /* yacc.c:1646 */
{
in_function = NULL;
(void) mk_function((yyvsp[-1]), (yyvsp[0]));
yyerrok;
}
-#line 1912 "awkgram.c" /* yacc.c:1646 */
+#line 1913 "awkgram.c" /* yacc.c:1646 */
break;
case 10:
-#line 251 "awkgram.y" /* yacc.c:1646 */
+#line 252 "awkgram.y" /* yacc.c:1646 */
{
want_source = false;
+ at_seen = false;
yyerrok;
}
-#line 1921 "awkgram.c" /* yacc.c:1646 */
+#line 1923 "awkgram.c" /* yacc.c:1646 */
break;
case 11:
-#line 256 "awkgram.y" /* yacc.c:1646 */
+#line 258 "awkgram.y" /* yacc.c:1646 */
{
want_source = false;
+ at_seen = false;
yyerrok;
}
-#line 1930 "awkgram.c" /* yacc.c:1646 */
+#line 1933 "awkgram.c" /* yacc.c:1646 */
break;
case 12:
-#line 264 "awkgram.y" /* yacc.c:1646 */
+#line 267 "awkgram.y" /* yacc.c:1646 */
{
if (include_source((yyvsp[0])) < 0)
YYABORT;
@@ -1938,23 +1941,23 @@ yyreduce:
bcfree((yyvsp[0]));
(yyval) = NULL;
}
-#line 1942 "awkgram.c" /* yacc.c:1646 */
+#line 1945 "awkgram.c" /* yacc.c:1646 */
break;
case 13:
-#line 272 "awkgram.y" /* yacc.c:1646 */
+#line 275 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 1948 "awkgram.c" /* yacc.c:1646 */
+#line 1951 "awkgram.c" /* yacc.c:1646 */
break;
case 14:
-#line 274 "awkgram.y" /* yacc.c:1646 */
+#line 277 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 1954 "awkgram.c" /* yacc.c:1646 */
+#line 1957 "awkgram.c" /* yacc.c:1646 */
break;
case 15:
-#line 279 "awkgram.y" /* yacc.c:1646 */
+#line 282 "awkgram.y" /* yacc.c:1646 */
{
if (load_library((yyvsp[0])) < 0)
YYABORT;
@@ -1962,23 +1965,23 @@ yyreduce:
bcfree((yyvsp[0]));
(yyval) = NULL;
}
-#line 1966 "awkgram.c" /* yacc.c:1646 */
+#line 1969 "awkgram.c" /* yacc.c:1646 */
break;
case 16:
-#line 287 "awkgram.y" /* yacc.c:1646 */
+#line 290 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 1972 "awkgram.c" /* yacc.c:1646 */
+#line 1975 "awkgram.c" /* yacc.c:1646 */
break;
case 17:
-#line 289 "awkgram.y" /* yacc.c:1646 */
+#line 292 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 1978 "awkgram.c" /* yacc.c:1646 */
+#line 1981 "awkgram.c" /* yacc.c:1646 */
break;
case 18:
-#line 294 "awkgram.y" /* yacc.c:1646 */
+#line 297 "awkgram.y" /* yacc.c:1646 */
{
rule = Rule;
if (comment != NULL) {
@@ -1987,11 +1990,11 @@ yyreduce:
} else
(yyval) = NULL;
}
-#line 1991 "awkgram.c" /* yacc.c:1646 */
+#line 1994 "awkgram.c" /* yacc.c:1646 */
break;
case 19:
-#line 303 "awkgram.y" /* yacc.c:1646 */
+#line 306 "awkgram.y" /* yacc.c:1646 */
{
rule = Rule;
if (comment != NULL) {
@@ -2000,11 +2003,11 @@ yyreduce:
} else
(yyval) = (yyvsp[0]);
}
-#line 2004 "awkgram.c" /* yacc.c:1646 */
+#line 2007 "awkgram.c" /* yacc.c:1646 */
break;
case 20:
-#line 313 "awkgram.y" /* yacc.c:1646 */
+#line 316 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *tp;
@@ -2034,11 +2037,11 @@ yyreduce:
(yyval) = list_append(list_merge((yyvsp[-3]), (yyvsp[0])), tp);
rule = Rule;
}
-#line 2038 "awkgram.c" /* yacc.c:1646 */
+#line 2041 "awkgram.c" /* yacc.c:1646 */
break;
case 21:
-#line 343 "awkgram.y" /* yacc.c:1646 */
+#line 346 "awkgram.y" /* yacc.c:1646 */
{
static int begin_seen = 0;
@@ -2052,11 +2055,11 @@ yyreduce:
check_comment();
(yyval) = (yyvsp[0]);
}
-#line 2056 "awkgram.c" /* yacc.c:1646 */
+#line 2059 "awkgram.c" /* yacc.c:1646 */
break;
case 22:
-#line 357 "awkgram.y" /* yacc.c:1646 */
+#line 360 "awkgram.y" /* yacc.c:1646 */
{
static int end_seen = 0;
@@ -2070,11 +2073,11 @@ yyreduce:
check_comment();
(yyval) = (yyvsp[0]);
}
-#line 2074 "awkgram.c" /* yacc.c:1646 */
+#line 2077 "awkgram.c" /* yacc.c:1646 */
break;
case 23:
-#line 371 "awkgram.y" /* yacc.c:1646 */
+#line 374 "awkgram.y" /* yacc.c:1646 */
{
func_first = false;
(yyvsp[0])->in_rule = rule = BEGINFILE;
@@ -2082,11 +2085,11 @@ yyreduce:
check_comment();
(yyval) = (yyvsp[0]);
}
-#line 2086 "awkgram.c" /* yacc.c:1646 */
+#line 2089 "awkgram.c" /* yacc.c:1646 */
break;
case 24:
-#line 379 "awkgram.y" /* yacc.c:1646 */
+#line 382 "awkgram.y" /* yacc.c:1646 */
{
func_first = false;
(yyvsp[0])->in_rule = rule = ENDFILE;
@@ -2094,11 +2097,11 @@ yyreduce:
check_comment();
(yyval) = (yyvsp[0]);
}
-#line 2098 "awkgram.c" /* yacc.c:1646 */
+#line 2101 "awkgram.c" /* yacc.c:1646 */
break;
case 25:
-#line 390 "awkgram.y" /* yacc.c:1646 */
+#line 393 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *ip;
if ((yyvsp[-3]) == NULL)
@@ -2107,39 +2110,42 @@ yyreduce:
ip = (yyvsp[-3]);
(yyval) = ip;
}
-#line 2111 "awkgram.c" /* yacc.c:1646 */
+#line 2114 "awkgram.c" /* yacc.c:1646 */
break;
case 26:
-#line 402 "awkgram.y" /* yacc.c:1646 */
+#line 405 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 2117 "awkgram.c" /* yacc.c:1646 */
+#line 2120 "awkgram.c" /* yacc.c:1646 */
break;
case 27:
-#line 404 "awkgram.y" /* yacc.c:1646 */
+#line 407 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 2123 "awkgram.c" /* yacc.c:1646 */
+#line 2126 "awkgram.c" /* yacc.c:1646 */
break;
case 28:
-#line 406 "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 2133 "awkgram.c" /* yacc.c:1646 */
+#line 2136 "awkgram.c" /* yacc.c:1646 */
break;
case 29:
-#line 412 "awkgram.y" /* yacc.c:1646 */
- { (yyval) = (yyvsp[0]); }
-#line 2139 "awkgram.c" /* yacc.c:1646 */
+#line 415 "awkgram.y" /* yacc.c:1646 */
+ {
+ (yyval) = (yyvsp[0]);
+ at_seen = false;
+ }
+#line 2145 "awkgram.c" /* yacc.c:1646 */
break;
case 32:
-#line 422 "awkgram.y" /* yacc.c:1646 */
+#line 428 "awkgram.y" /* yacc.c:1646 */
{
/*
* treat any comments between BOF and the first function
@@ -2166,17 +2172,17 @@ yyreduce:
/* $4 already free'd in install_function */
(yyval) = (yyvsp[-5]);
}
-#line 2170 "awkgram.c" /* yacc.c:1646 */
+#line 2176 "awkgram.c" /* yacc.c:1646 */
break;
case 33:
-#line 456 "awkgram.y" /* yacc.c:1646 */
+#line 462 "awkgram.y" /* yacc.c:1646 */
{ want_regexp = true; }
-#line 2176 "awkgram.c" /* yacc.c:1646 */
+#line 2182 "awkgram.c" /* yacc.c:1646 */
break;
case 34:
-#line 458 "awkgram.y" /* yacc.c:1646 */
+#line 464 "awkgram.y" /* yacc.c:1646 */
{
NODE *n, *exp;
char *re;
@@ -2205,28 +2211,28 @@ yyreduce:
(yyval)->opcode = Op_match_rec;
(yyval)->memory = n;
}
-#line 2209 "awkgram.c" /* yacc.c:1646 */
+#line 2215 "awkgram.c" /* yacc.c:1646 */
break;
case 35:
-#line 490 "awkgram.y" /* yacc.c:1646 */
+#line 496 "awkgram.y" /* yacc.c:1646 */
{ bcfree((yyvsp[0])); }
-#line 2215 "awkgram.c" /* yacc.c:1646 */
+#line 2221 "awkgram.c" /* yacc.c:1646 */
break;
case 37:
-#line 496 "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 2226 "awkgram.c" /* yacc.c:1646 */
+#line 2232 "awkgram.c" /* yacc.c:1646 */
break;
case 38:
-#line 503 "awkgram.y" /* yacc.c:1646 */
+#line 509 "awkgram.y" /* yacc.c:1646 */
{
if ((yyvsp[0]) == NULL) {
if (comment == NULL)
@@ -2254,40 +2260,40 @@ yyreduce:
}
yyerrok;
}
-#line 2258 "awkgram.c" /* yacc.c:1646 */
+#line 2264 "awkgram.c" /* yacc.c:1646 */
break;
case 39:
-#line 531 "awkgram.y" /* yacc.c:1646 */
+#line 537 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 2264 "awkgram.c" /* yacc.c:1646 */
+#line 2270 "awkgram.c" /* yacc.c:1646 */
break;
case 42:
-#line 541 "awkgram.y" /* yacc.c:1646 */
+#line 547 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 2270 "awkgram.c" /* yacc.c:1646 */
+#line 2276 "awkgram.c" /* yacc.c:1646 */
break;
case 43:
-#line 543 "awkgram.y" /* yacc.c:1646 */
+#line 549 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[-1]); }
-#line 2276 "awkgram.c" /* yacc.c:1646 */
+#line 2282 "awkgram.c" /* yacc.c:1646 */
break;
case 44:
-#line 545 "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 2287 "awkgram.c" /* yacc.c:1646 */
+#line 2293 "awkgram.c" /* yacc.c:1646 */
break;
case 45:
-#line 552 "awkgram.y" /* yacc.c:1646 */
+#line 558 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *dflt, *curr = NULL, *cexp, *cstmt;
INSTRUCTION *ip, *nextc, *tbreak;
@@ -2377,11 +2383,11 @@ yyreduce:
break_allowed--;
fix_break_continue(ip, tbreak, NULL);
}
-#line 2381 "awkgram.c" /* yacc.c:1646 */
+#line 2387 "awkgram.c" /* yacc.c:1646 */
break;
case 46:
-#line 642 "awkgram.y" /* yacc.c:1646 */
+#line 648 "awkgram.y" /* yacc.c:1646 */
{
/*
* -----------------
@@ -2423,11 +2429,11 @@ yyreduce:
continue_allowed--;
fix_break_continue(ip, tbreak, tcont);
}
-#line 2427 "awkgram.c" /* yacc.c:1646 */
+#line 2433 "awkgram.c" /* yacc.c:1646 */
break;
case 47:
-#line 684 "awkgram.y" /* yacc.c:1646 */
+#line 690 "awkgram.y" /* yacc.c:1646 */
{
/*
* -----------------
@@ -2469,11 +2475,11 @@ yyreduce:
} /* else
$1 and $4 are NULLs */
}
-#line 2473 "awkgram.c" /* yacc.c:1646 */
+#line 2479 "awkgram.c" /* yacc.c:1646 */
break;
case 48:
-#line 726 "awkgram.y" /* yacc.c:1646 */
+#line 732 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *ip;
char *var_name = (yyvsp[-5])->lextok;
@@ -2586,44 +2592,44 @@ regular_loop:
break_allowed--;
continue_allowed--;
}
-#line 2590 "awkgram.c" /* yacc.c:1646 */
+#line 2596 "awkgram.c" /* yacc.c:1646 */
break;
case 49:
-#line 839 "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 2601 "awkgram.c" /* yacc.c:1646 */
+#line 2607 "awkgram.c" /* yacc.c:1646 */
break;
case 50:
-#line 846 "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 2612 "awkgram.c" /* yacc.c:1646 */
+#line 2618 "awkgram.c" /* yacc.c:1646 */
break;
case 51:
-#line 853 "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 2623 "awkgram.c" /* yacc.c:1646 */
+#line 2629 "awkgram.c" /* yacc.c:1646 */
break;
case 52:
-#line 863 "awkgram.y" /* yacc.c:1646 */
+#line 869 "awkgram.y" /* yacc.c:1646 */
{
if (! break_allowed)
error_ln((yyvsp[-1])->source_line,
@@ -2632,11 +2638,11 @@ regular_loop:
(yyval) = list_create((yyvsp[-1]));
}
-#line 2636 "awkgram.c" /* yacc.c:1646 */
+#line 2642 "awkgram.c" /* yacc.c:1646 */
break;
case 53:
-#line 872 "awkgram.y" /* yacc.c:1646 */
+#line 878 "awkgram.y" /* yacc.c:1646 */
{
if (! continue_allowed)
error_ln((yyvsp[-1])->source_line,
@@ -2645,11 +2651,11 @@ regular_loop:
(yyval) = list_create((yyvsp[-1]));
}
-#line 2649 "awkgram.c" /* yacc.c:1646 */
+#line 2655 "awkgram.c" /* yacc.c:1646 */
break;
case 54:
-#line 881 "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)
@@ -2658,11 +2664,11 @@ regular_loop:
(yyvsp[-1])->target_jmp = ip_rec;
(yyval) = list_create((yyvsp[-1]));
}
-#line 2662 "awkgram.c" /* yacc.c:1646 */
+#line 2668 "awkgram.c" /* yacc.c:1646 */
break;
case 55:
-#line 890 "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)
@@ -2673,11 +2679,11 @@ regular_loop:
(yyvsp[-1])->target_endfile = ip_endfile;
(yyval) = list_create((yyvsp[-1]));
}
-#line 2677 "awkgram.c" /* yacc.c:1646 */
+#line 2683 "awkgram.c" /* yacc.c:1646 */
break;
case 56:
-#line 901 "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.
@@ -2692,20 +2698,20 @@ regular_loop:
} else
(yyval) = list_append((yyvsp[-1]), (yyvsp[-2]));
}
-#line 2696 "awkgram.c" /* yacc.c:1646 */
+#line 2702 "awkgram.c" /* yacc.c:1646 */
break;
case 57:
-#line 916 "awkgram.y" /* yacc.c:1646 */
+#line 922 "awkgram.y" /* yacc.c:1646 */
{
if (! in_function)
yyerror(_("`return' used outside function context"));
}
-#line 2705 "awkgram.c" /* yacc.c:1646 */
+#line 2711 "awkgram.c" /* yacc.c:1646 */
break;
case 58:
-#line 919 "awkgram.y" /* yacc.c:1646 */
+#line 925 "awkgram.y" /* yacc.c:1646 */
{
if ((yyvsp[-1]) == NULL) {
(yyval) = list_create((yyvsp[-3]));
@@ -2726,17 +2732,17 @@ regular_loop:
(yyval) = list_append((yyvsp[-1]), (yyvsp[-3]));
}
}
-#line 2730 "awkgram.c" /* yacc.c:1646 */
+#line 2736 "awkgram.c" /* yacc.c:1646 */
break;
case 60:
-#line 951 "awkgram.y" /* yacc.c:1646 */
+#line 957 "awkgram.y" /* yacc.c:1646 */
{ in_print = true; in_parens = 0; }
-#line 2736 "awkgram.c" /* yacc.c:1646 */
+#line 2742 "awkgram.c" /* yacc.c:1646 */
break;
case 61:
-#line 952 "awkgram.y" /* yacc.c:1646 */
+#line 958 "awkgram.y" /* yacc.c:1646 */
{
/*
* Optimization: plain `print' has no expression list, so $3 is null.
@@ -2833,17 +2839,17 @@ regular_print:
}
}
}
-#line 2837 "awkgram.c" /* yacc.c:1646 */
+#line 2843 "awkgram.c" /* yacc.c:1646 */
break;
case 62:
-#line 1049 "awkgram.y" /* yacc.c:1646 */
+#line 1055 "awkgram.y" /* yacc.c:1646 */
{ sub_counter = 0; }
-#line 2843 "awkgram.c" /* yacc.c:1646 */
+#line 2849 "awkgram.c" /* yacc.c:1646 */
break;
case 63:
-#line 1050 "awkgram.y" /* yacc.c:1646 */
+#line 1056 "awkgram.y" /* yacc.c:1646 */
{
char *arr = (yyvsp[-2])->lextok;
@@ -2876,11 +2882,11 @@ regular_print:
(yyval) = list_append(list_append((yyvsp[0]), (yyvsp[-2])), (yyvsp[-3]));
}
}
-#line 2880 "awkgram.c" /* yacc.c:1646 */
+#line 2886 "awkgram.c" /* yacc.c:1646 */
break;
case 64:
-#line 1087 "awkgram.y" /* yacc.c:1646 */
+#line 1093 "awkgram.y" /* yacc.c:1646 */
{
static bool warned = false;
char *arr = (yyvsp[-1])->lextok;
@@ -2906,52 +2912,52 @@ regular_print:
fatal(_("`delete' is not allowed with FUNCTAB"));
}
}
-#line 2910 "awkgram.c" /* yacc.c:1646 */
+#line 2916 "awkgram.c" /* yacc.c:1646 */
break;
case 65:
-#line 1113 "awkgram.y" /* yacc.c:1646 */
+#line 1119 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = optimize_assignment((yyvsp[0])); }
-#line 2916 "awkgram.c" /* yacc.c:1646 */
+#line 2922 "awkgram.c" /* yacc.c:1646 */
break;
case 66:
-#line 1118 "awkgram.y" /* yacc.c:1646 */
+#line 1124 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 2922 "awkgram.c" /* yacc.c:1646 */
+#line 2928 "awkgram.c" /* yacc.c:1646 */
break;
case 67:
-#line 1120 "awkgram.y" /* yacc.c:1646 */
+#line 1126 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 2928 "awkgram.c" /* yacc.c:1646 */
+#line 2934 "awkgram.c" /* yacc.c:1646 */
break;
case 68:
-#line 1125 "awkgram.y" /* yacc.c:1646 */
+#line 1131 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 2934 "awkgram.c" /* yacc.c:1646 */
+#line 2940 "awkgram.c" /* yacc.c:1646 */
break;
case 69:
-#line 1127 "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 2945 "awkgram.c" /* yacc.c:1646 */
+#line 2951 "awkgram.c" /* yacc.c:1646 */
break;
case 70:
-#line 1134 "awkgram.y" /* yacc.c:1646 */
+#line 1140 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 2951 "awkgram.c" /* yacc.c:1646 */
+#line 2957 "awkgram.c" /* yacc.c:1646 */
break;
case 71:
-#line 1139 "awkgram.y" /* yacc.c:1646 */
+#line 1145 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *casestmt = (yyvsp[0]);
if ((yyvsp[0]) == NULL)
@@ -2963,11 +2969,11 @@ regular_print:
bcfree((yyvsp[-2]));
(yyval) = (yyvsp[-4]);
}
-#line 2967 "awkgram.c" /* yacc.c:1646 */
+#line 2973 "awkgram.c" /* yacc.c:1646 */
break;
case 72:
-#line 1151 "awkgram.y" /* yacc.c:1646 */
+#line 1157 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *casestmt = (yyvsp[0]);
if ((yyvsp[0]) == NULL)
@@ -2978,17 +2984,17 @@ regular_print:
(yyvsp[-3])->case_stmt = casestmt;
(yyval) = (yyvsp[-3]);
}
-#line 2982 "awkgram.c" /* yacc.c:1646 */
+#line 2988 "awkgram.c" /* yacc.c:1646 */
break;
case 73:
-#line 1165 "awkgram.y" /* yacc.c:1646 */
+#line 1171 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 2988 "awkgram.c" /* yacc.c:1646 */
+#line 2994 "awkgram.c" /* yacc.c:1646 */
break;
case 74:
-#line 1167 "awkgram.y" /* yacc.c:1646 */
+#line 1173 "awkgram.y" /* yacc.c:1646 */
{
NODE *n = (yyvsp[0])->memory;
(void) force_number(n);
@@ -2996,71 +3002,71 @@ regular_print:
bcfree((yyvsp[-1]));
(yyval) = (yyvsp[0]);
}
-#line 3000 "awkgram.c" /* yacc.c:1646 */
+#line 3006 "awkgram.c" /* yacc.c:1646 */
break;
case 75:
-#line 1175 "awkgram.y" /* yacc.c:1646 */
+#line 1181 "awkgram.y" /* yacc.c:1646 */
{
bcfree((yyvsp[-1]));
(yyval) = (yyvsp[0]);
}
-#line 3009 "awkgram.c" /* yacc.c:1646 */
+#line 3015 "awkgram.c" /* yacc.c:1646 */
break;
case 76:
-#line 1180 "awkgram.y" /* yacc.c:1646 */
+#line 1186 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3015 "awkgram.c" /* yacc.c:1646 */
+#line 3021 "awkgram.c" /* yacc.c:1646 */
break;
case 77:
-#line 1182 "awkgram.y" /* yacc.c:1646 */
+#line 1188 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[0])->opcode = Op_push_re;
(yyval) = (yyvsp[0]);
}
-#line 3024 "awkgram.c" /* yacc.c:1646 */
+#line 3030 "awkgram.c" /* yacc.c:1646 */
break;
case 78:
-#line 1190 "awkgram.y" /* yacc.c:1646 */
+#line 1196 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3030 "awkgram.c" /* yacc.c:1646 */
+#line 3036 "awkgram.c" /* yacc.c:1646 */
break;
case 79:
-#line 1192 "awkgram.y" /* yacc.c:1646 */
+#line 1198 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3036 "awkgram.c" /* yacc.c:1646 */
+#line 3042 "awkgram.c" /* yacc.c:1646 */
break;
case 81:
-#line 1202 "awkgram.y" /* yacc.c:1646 */
+#line 1208 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = (yyvsp[-1]);
}
-#line 3044 "awkgram.c" /* yacc.c:1646 */
+#line 3050 "awkgram.c" /* yacc.c:1646 */
break;
case 82:
-#line 1209 "awkgram.y" /* yacc.c:1646 */
+#line 1215 "awkgram.y" /* yacc.c:1646 */
{
in_print = false;
in_parens = 0;
(yyval) = NULL;
}
-#line 3054 "awkgram.c" /* yacc.c:1646 */
+#line 3060 "awkgram.c" /* yacc.c:1646 */
break;
case 83:
-#line 1214 "awkgram.y" /* yacc.c:1646 */
+#line 1220 "awkgram.y" /* yacc.c:1646 */
{ in_print = false; in_parens = 0; }
-#line 3060 "awkgram.c" /* yacc.c:1646 */
+#line 3066 "awkgram.c" /* yacc.c:1646 */
break;
case 84:
-#line 1215 "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
@@ -3068,136 +3074,136 @@ regular_print:
yyerror(_("multistage two-way pipelines don't work"));
(yyval) = list_prepend((yyvsp[0]), (yyvsp[-2]));
}
-#line 3072 "awkgram.c" /* yacc.c:1646 */
+#line 3078 "awkgram.c" /* yacc.c:1646 */
break;
case 85:
-#line 1226 "awkgram.y" /* yacc.c:1646 */
+#line 1232 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = mk_condition((yyvsp[-3]), (yyvsp[-5]), (yyvsp[0]), NULL, NULL);
}
-#line 3080 "awkgram.c" /* yacc.c:1646 */
+#line 3086 "awkgram.c" /* yacc.c:1646 */
break;
case 86:
-#line 1231 "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 3088 "awkgram.c" /* yacc.c:1646 */
+#line 3094 "awkgram.c" /* yacc.c:1646 */
break;
case 91:
-#line 1248 "awkgram.y" /* yacc.c:1646 */
+#line 1254 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3094 "awkgram.c" /* yacc.c:1646 */
+#line 3100 "awkgram.c" /* yacc.c:1646 */
break;
case 92:
-#line 1250 "awkgram.y" /* yacc.c:1646 */
+#line 1256 "awkgram.y" /* yacc.c:1646 */
{
bcfree((yyvsp[-1]));
(yyval) = (yyvsp[0]);
}
-#line 3103 "awkgram.c" /* yacc.c:1646 */
+#line 3109 "awkgram.c" /* yacc.c:1646 */
break;
case 93:
-#line 1258 "awkgram.y" /* yacc.c:1646 */
+#line 1264 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3109 "awkgram.c" /* yacc.c:1646 */
+#line 3115 "awkgram.c" /* yacc.c:1646 */
break;
case 94:
-#line 1260 "awkgram.y" /* yacc.c:1646 */
+#line 1266 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3115 "awkgram.c" /* yacc.c:1646 */
+#line 3121 "awkgram.c" /* yacc.c:1646 */
break;
case 95:
-#line 1265 "awkgram.y" /* yacc.c:1646 */
+#line 1271 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[0])->param_count = 0;
(yyval) = list_create((yyvsp[0]));
}
-#line 3124 "awkgram.c" /* yacc.c:1646 */
+#line 3130 "awkgram.c" /* yacc.c:1646 */
break;
case 96:
-#line 1270 "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 3134 "awkgram.c" /* yacc.c:1646 */
+#line 3140 "awkgram.c" /* yacc.c:1646 */
break;
case 97:
-#line 1276 "awkgram.y" /* yacc.c:1646 */
+#line 1282 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3140 "awkgram.c" /* yacc.c:1646 */
+#line 3146 "awkgram.c" /* yacc.c:1646 */
break;
case 98:
-#line 1278 "awkgram.y" /* yacc.c:1646 */
+#line 1284 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[-1]); }
-#line 3146 "awkgram.c" /* yacc.c:1646 */
+#line 3152 "awkgram.c" /* yacc.c:1646 */
break;
case 99:
-#line 1280 "awkgram.y" /* yacc.c:1646 */
+#line 1286 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[-2]); }
-#line 3152 "awkgram.c" /* yacc.c:1646 */
+#line 3158 "awkgram.c" /* yacc.c:1646 */
break;
case 100:
-#line 1286 "awkgram.y" /* yacc.c:1646 */
+#line 1292 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3158 "awkgram.c" /* yacc.c:1646 */
+#line 3164 "awkgram.c" /* yacc.c:1646 */
break;
case 101:
-#line 1288 "awkgram.y" /* yacc.c:1646 */
+#line 1294 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3164 "awkgram.c" /* yacc.c:1646 */
+#line 3170 "awkgram.c" /* yacc.c:1646 */
break;
case 102:
-#line 1293 "awkgram.y" /* yacc.c:1646 */
+#line 1299 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3170 "awkgram.c" /* yacc.c:1646 */
+#line 3176 "awkgram.c" /* yacc.c:1646 */
break;
case 103:
-#line 1295 "awkgram.y" /* yacc.c:1646 */
+#line 1301 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3176 "awkgram.c" /* yacc.c:1646 */
+#line 3182 "awkgram.c" /* yacc.c:1646 */
break;
case 104:
-#line 1300 "awkgram.y" /* yacc.c:1646 */
+#line 1306 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_expression_list(NULL, (yyvsp[0])); }
-#line 3182 "awkgram.c" /* yacc.c:1646 */
+#line 3188 "awkgram.c" /* yacc.c:1646 */
break;
case 105:
-#line 1302 "awkgram.y" /* yacc.c:1646 */
+#line 1308 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0]));
yyerrok;
}
-#line 3191 "awkgram.c" /* yacc.c:1646 */
+#line 3197 "awkgram.c" /* yacc.c:1646 */
break;
case 106:
-#line 1307 "awkgram.y" /* yacc.c:1646 */
+#line 1313 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3197 "awkgram.c" /* yacc.c:1646 */
+#line 3203 "awkgram.c" /* yacc.c:1646 */
break;
case 107:
-#line 1309 "awkgram.y" /* yacc.c:1646 */
+#line 1315 "awkgram.y" /* yacc.c:1646 */
{
/*
* Returning the expression list instead of NULL lets
@@ -3205,52 +3211,52 @@ regular_print:
*/
(yyval) = (yyvsp[-1]);
}
-#line 3209 "awkgram.c" /* yacc.c:1646 */
+#line 3215 "awkgram.c" /* yacc.c:1646 */
break;
case 108:
-#line 1317 "awkgram.y" /* yacc.c:1646 */
+#line 1323 "awkgram.y" /* yacc.c:1646 */
{
/* Ditto */
(yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0]));
}
-#line 3218 "awkgram.c" /* yacc.c:1646 */
+#line 3224 "awkgram.c" /* yacc.c:1646 */
break;
case 109:
-#line 1322 "awkgram.y" /* yacc.c:1646 */
+#line 1328 "awkgram.y" /* yacc.c:1646 */
{
/* Ditto */
(yyval) = (yyvsp[-2]);
}
-#line 3227 "awkgram.c" /* yacc.c:1646 */
+#line 3233 "awkgram.c" /* yacc.c:1646 */
break;
case 110:
-#line 1331 "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 3238 "awkgram.c" /* yacc.c:1646 */
+#line 3244 "awkgram.c" /* yacc.c:1646 */
break;
case 111:
-#line 1338 "awkgram.y" /* yacc.c:1646 */
+#line 1344 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3244 "awkgram.c" /* yacc.c:1646 */
+#line 3250 "awkgram.c" /* yacc.c:1646 */
break;
case 112:
-#line 1340 "awkgram.y" /* yacc.c:1646 */
+#line 1346 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3250 "awkgram.c" /* yacc.c:1646 */
+#line 3256 "awkgram.c" /* yacc.c:1646 */
break;
case 113:
-#line 1342 "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,
@@ -3266,11 +3272,11 @@ regular_print:
(yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1]));
}
}
-#line 3270 "awkgram.c" /* yacc.c:1646 */
+#line 3276 "awkgram.c" /* yacc.c:1646 */
break;
case 114:
-#line 1358 "awkgram.y" /* yacc.c:1646 */
+#line 1364 "awkgram.y" /* yacc.c:1646 */
{
if (do_lint_old)
warning_ln((yyvsp[-1])->source_line,
@@ -3280,91 +3286,91 @@ regular_print:
(yyvsp[-1])->expr_count = 1;
(yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1]));
}
-#line 3284 "awkgram.c" /* yacc.c:1646 */
+#line 3290 "awkgram.c" /* yacc.c:1646 */
break;
case 115:
-#line 1368 "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 3295 "awkgram.c" /* yacc.c:1646 */
+#line 3301 "awkgram.c" /* yacc.c:1646 */
break;
case 116:
-#line 1375 "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 3301 "awkgram.c" /* yacc.c:1646 */
+#line 3307 "awkgram.c" /* yacc.c:1646 */
break;
case 117:
-#line 1377 "awkgram.y" /* yacc.c:1646 */
+#line 1383 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3307 "awkgram.c" /* yacc.c:1646 */
+#line 3313 "awkgram.c" /* yacc.c:1646 */
break;
case 118:
-#line 1382 "awkgram.y" /* yacc.c:1646 */
+#line 1388 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3313 "awkgram.c" /* yacc.c:1646 */
+#line 3319 "awkgram.c" /* yacc.c:1646 */
break;
case 119:
-#line 1384 "awkgram.y" /* yacc.c:1646 */
+#line 1390 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3319 "awkgram.c" /* yacc.c:1646 */
+#line 3325 "awkgram.c" /* yacc.c:1646 */
break;
case 120:
-#line 1386 "awkgram.y" /* yacc.c:1646 */
+#line 1392 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[0])->opcode = Op_assign_quotient;
(yyval) = (yyvsp[0]);
}
-#line 3328 "awkgram.c" /* yacc.c:1646 */
+#line 3334 "awkgram.c" /* yacc.c:1646 */
break;
case 121:
-#line 1394 "awkgram.y" /* yacc.c:1646 */
+#line 1400 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3334 "awkgram.c" /* yacc.c:1646 */
+#line 3340 "awkgram.c" /* yacc.c:1646 */
break;
case 122:
-#line 1396 "awkgram.y" /* yacc.c:1646 */
+#line 1402 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3340 "awkgram.c" /* yacc.c:1646 */
+#line 3346 "awkgram.c" /* yacc.c:1646 */
break;
case 123:
-#line 1401 "awkgram.y" /* yacc.c:1646 */
+#line 1407 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3346 "awkgram.c" /* yacc.c:1646 */
+#line 3352 "awkgram.c" /* yacc.c:1646 */
break;
case 124:
-#line 1403 "awkgram.y" /* yacc.c:1646 */
+#line 1409 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3352 "awkgram.c" /* yacc.c:1646 */
+#line 3358 "awkgram.c" /* yacc.c:1646 */
break;
case 125:
-#line 1408 "awkgram.y" /* yacc.c:1646 */
+#line 1414 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3358 "awkgram.c" /* yacc.c:1646 */
+#line 3364 "awkgram.c" /* yacc.c:1646 */
break;
case 126:
-#line 1410 "awkgram.y" /* yacc.c:1646 */
+#line 1416 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3364 "awkgram.c" /* yacc.c:1646 */
+#line 3370 "awkgram.c" /* yacc.c:1646 */
break;
case 127:
-#line 1412 "awkgram.y" /* yacc.c:1646 */
+#line 1418 "awkgram.y" /* yacc.c:1646 */
{
int count = 2;
bool is_simple_var = false;
@@ -3411,47 +3417,47 @@ regular_print:
max_args = count;
}
}
-#line 3415 "awkgram.c" /* yacc.c:1646 */
+#line 3421 "awkgram.c" /* yacc.c:1646 */
break;
case 129:
-#line 1464 "awkgram.y" /* yacc.c:1646 */
+#line 1470 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3421 "awkgram.c" /* yacc.c:1646 */
+#line 3427 "awkgram.c" /* yacc.c:1646 */
break;
case 130:
-#line 1466 "awkgram.y" /* yacc.c:1646 */
+#line 1472 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3427 "awkgram.c" /* yacc.c:1646 */
+#line 3433 "awkgram.c" /* yacc.c:1646 */
break;
case 131:
-#line 1468 "awkgram.y" /* yacc.c:1646 */
+#line 1474 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3433 "awkgram.c" /* yacc.c:1646 */
+#line 3439 "awkgram.c" /* yacc.c:1646 */
break;
case 132:
-#line 1470 "awkgram.y" /* yacc.c:1646 */
+#line 1476 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3439 "awkgram.c" /* yacc.c:1646 */
+#line 3445 "awkgram.c" /* yacc.c:1646 */
break;
case 133:
-#line 1472 "awkgram.y" /* yacc.c:1646 */
+#line 1478 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3445 "awkgram.c" /* yacc.c:1646 */
+#line 3451 "awkgram.c" /* yacc.c:1646 */
break;
case 134:
-#line 1474 "awkgram.y" /* yacc.c:1646 */
+#line 1480 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3451 "awkgram.c" /* yacc.c:1646 */
+#line 3457 "awkgram.c" /* yacc.c:1646 */
break;
case 135:
-#line 1476 "awkgram.y" /* yacc.c:1646 */
+#line 1482 "awkgram.y" /* yacc.c:1646 */
{
/*
* In BEGINFILE/ENDFILE, allow `getline [var] < file'
@@ -3465,29 +3471,29 @@ regular_print:
_("non-redirected `getline' undefined inside END action"));
(yyval) = mk_getline((yyvsp[-2]), (yyvsp[-1]), (yyvsp[0]), redirect_input);
}
-#line 3469 "awkgram.c" /* yacc.c:1646 */
+#line 3475 "awkgram.c" /* yacc.c:1646 */
break;
case 136:
-#line 1490 "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 3478 "awkgram.c" /* yacc.c:1646 */
+#line 3484 "awkgram.c" /* yacc.c:1646 */
break;
case 137:
-#line 1495 "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 3487 "awkgram.c" /* yacc.c:1646 */
+#line 3493 "awkgram.c" /* yacc.c:1646 */
break;
case 138:
-#line 1500 "awkgram.y" /* yacc.c:1646 */
+#line 1506 "awkgram.y" /* yacc.c:1646 */
{
if (do_lint_old) {
warning_ln((yyvsp[-1])->source_line,
@@ -3507,64 +3513,64 @@ regular_print:
(yyval) = list_append(list_merge(t, (yyvsp[0])), (yyvsp[-1]));
}
}
-#line 3511 "awkgram.c" /* yacc.c:1646 */
+#line 3517 "awkgram.c" /* yacc.c:1646 */
break;
case 139:
-#line 1525 "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 3520 "awkgram.c" /* yacc.c:1646 */
+#line 3526 "awkgram.c" /* yacc.c:1646 */
break;
case 140:
-#line 1531 "awkgram.y" /* yacc.c:1646 */
+#line 1537 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3526 "awkgram.c" /* yacc.c:1646 */
+#line 3532 "awkgram.c" /* yacc.c:1646 */
break;
case 141:
-#line 1533 "awkgram.y" /* yacc.c:1646 */
+#line 1539 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3532 "awkgram.c" /* yacc.c:1646 */
+#line 3538 "awkgram.c" /* yacc.c:1646 */
break;
case 142:
-#line 1535 "awkgram.y" /* yacc.c:1646 */
+#line 1541 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3538 "awkgram.c" /* yacc.c:1646 */
+#line 3544 "awkgram.c" /* yacc.c:1646 */
break;
case 143:
-#line 1537 "awkgram.y" /* yacc.c:1646 */
+#line 1543 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3544 "awkgram.c" /* yacc.c:1646 */
+#line 3550 "awkgram.c" /* yacc.c:1646 */
break;
case 144:
-#line 1539 "awkgram.y" /* yacc.c:1646 */
+#line 1545 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3550 "awkgram.c" /* yacc.c:1646 */
+#line 3556 "awkgram.c" /* yacc.c:1646 */
break;
case 145:
-#line 1541 "awkgram.y" /* yacc.c:1646 */
+#line 1547 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3556 "awkgram.c" /* yacc.c:1646 */
+#line 3562 "awkgram.c" /* yacc.c:1646 */
break;
case 146:
-#line 1546 "awkgram.y" /* yacc.c:1646 */
+#line 1552 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = list_create((yyvsp[0]));
}
-#line 3564 "awkgram.c" /* yacc.c:1646 */
+#line 3570 "awkgram.c" /* yacc.c:1646 */
break;
case 147:
-#line 1550 "awkgram.y" /* yacc.c:1646 */
+#line 1556 "awkgram.y" /* yacc.c:1646 */
{
if ((yyvsp[0])->opcode == Op_match_rec) {
(yyvsp[0])->opcode = Op_nomatch;
@@ -3596,37 +3602,37 @@ regular_print:
}
}
}
-#line 3600 "awkgram.c" /* yacc.c:1646 */
+#line 3606 "awkgram.c" /* yacc.c:1646 */
break;
case 148:
-#line 1582 "awkgram.y" /* yacc.c:1646 */
+#line 1588 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[-1]); }
-#line 3606 "awkgram.c" /* yacc.c:1646 */
+#line 3612 "awkgram.c" /* yacc.c:1646 */
break;
case 149:
-#line 1584 "awkgram.y" /* yacc.c:1646 */
+#line 1590 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = snode((yyvsp[-1]), (yyvsp[-3]));
if ((yyval) == NULL)
YYABORT;
}
-#line 3616 "awkgram.c" /* yacc.c:1646 */
+#line 3622 "awkgram.c" /* yacc.c:1646 */
break;
case 150:
-#line 1590 "awkgram.y" /* yacc.c:1646 */
+#line 1596 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = snode((yyvsp[-1]), (yyvsp[-3]));
if ((yyval) == NULL)
YYABORT;
}
-#line 3626 "awkgram.c" /* yacc.c:1646 */
+#line 3632 "awkgram.c" /* yacc.c:1646 */
break;
case 151:
-#line 1596 "awkgram.y" /* yacc.c:1646 */
+#line 1602 "awkgram.y" /* yacc.c:1646 */
{
static bool warned = false;
@@ -3639,45 +3645,45 @@ regular_print:
if ((yyval) == NULL)
YYABORT;
}
-#line 3643 "awkgram.c" /* yacc.c:1646 */
+#line 3649 "awkgram.c" /* yacc.c:1646 */
break;
case 154:
-#line 1611 "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 3652 "awkgram.c" /* yacc.c:1646 */
+#line 3658 "awkgram.c" /* yacc.c:1646 */
break;
case 155:
-#line 1616 "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 3661 "awkgram.c" /* yacc.c:1646 */
+#line 3667 "awkgram.c" /* yacc.c:1646 */
break;
case 156:
-#line 1621 "awkgram.y" /* yacc.c:1646 */
+#line 1627 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = list_create((yyvsp[0]));
}
-#line 3669 "awkgram.c" /* yacc.c:1646 */
+#line 3675 "awkgram.c" /* yacc.c:1646 */
break;
case 157:
-#line 1625 "awkgram.y" /* yacc.c:1646 */
+#line 1631 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = list_create((yyvsp[0]));
}
-#line 3677 "awkgram.c" /* yacc.c:1646 */
+#line 3683 "awkgram.c" /* yacc.c:1646 */
break;
case 158:
-#line 1629 "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
@@ -3692,11 +3698,11 @@ regular_print:
(yyval) = list_append((yyvsp[0]), (yyvsp[-1]));
}
}
-#line 3696 "awkgram.c" /* yacc.c:1646 */
+#line 3702 "awkgram.c" /* yacc.c:1646 */
break;
case 159:
-#line 1644 "awkgram.y" /* yacc.c:1646 */
+#line 1650 "awkgram.y" /* yacc.c:1646 */
{
/*
* was: $$ = $2
@@ -3706,20 +3712,20 @@ regular_print:
(yyvsp[-1])->memory = make_number(0.0);
(yyval) = list_append((yyvsp[0]), (yyvsp[-1]));
}
-#line 3710 "awkgram.c" /* yacc.c:1646 */
+#line 3716 "awkgram.c" /* yacc.c:1646 */
break;
case 160:
-#line 1657 "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 3719 "awkgram.c" /* yacc.c:1646 */
+#line 3725 "awkgram.c" /* yacc.c:1646 */
break;
case 161:
-#line 1662 "awkgram.y" /* yacc.c:1646 */
+#line 1668 "awkgram.y" /* yacc.c:1646 */
{
/* indirect function call */
INSTRUCTION *f, *t;
@@ -3751,13 +3757,25 @@ regular_print:
*/
(yyval) = list_prepend((yyvsp[0]), t);
+ at_seen = false;
}
-#line 3756 "awkgram.c" /* yacc.c:1646 */
+#line 3763 "awkgram.c" /* yacc.c:1646 */
break;
case 162:
-#line 1698 "awkgram.y" /* yacc.c:1646 */
+#line 1705 "awkgram.y" /* yacc.c:1646 */
{
+ NODE *n;
+
+ if (! at_seen) {
+ n = lookup((yyvsp[-3])->func_name);
+ if (n != NULL && n->type != Node_func
+ && n->type != Node_ext_func && n->type != Node_old_ext_func) {
+ error_ln((yyvsp[-3])->source_line,
+ _("attempt to use non-function `%s' in function call"),
+ (yyvsp[-3])->func_name);
+ }
+ }
param_sanity((yyvsp[-1]));
(yyvsp[-3])->opcode = Op_func_call;
(yyvsp[-3])->func_body = NULL;
@@ -3770,49 +3788,49 @@ regular_print:
(yyval) = list_append(t, (yyvsp[-3]));
}
}
-#line 3774 "awkgram.c" /* yacc.c:1646 */
+#line 3792 "awkgram.c" /* yacc.c:1646 */
break;
case 163:
-#line 1715 "awkgram.y" /* yacc.c:1646 */
+#line 1733 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3780 "awkgram.c" /* yacc.c:1646 */
+#line 3798 "awkgram.c" /* yacc.c:1646 */
break;
case 164:
-#line 1717 "awkgram.y" /* yacc.c:1646 */
+#line 1735 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3786 "awkgram.c" /* yacc.c:1646 */
+#line 3804 "awkgram.c" /* yacc.c:1646 */
break;
case 165:
-#line 1722 "awkgram.y" /* yacc.c:1646 */
+#line 1740 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3792 "awkgram.c" /* yacc.c:1646 */
+#line 3810 "awkgram.c" /* yacc.c:1646 */
break;
case 166:
-#line 1724 "awkgram.y" /* yacc.c:1646 */
+#line 1742 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[-1]); }
-#line 3798 "awkgram.c" /* yacc.c:1646 */
+#line 3816 "awkgram.c" /* yacc.c:1646 */
break;
case 167:
-#line 1729 "awkgram.y" /* yacc.c:1646 */
+#line 1747 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3804 "awkgram.c" /* yacc.c:1646 */
+#line 3822 "awkgram.c" /* yacc.c:1646 */
break;
case 168:
-#line 1731 "awkgram.y" /* yacc.c:1646 */
+#line 1749 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = list_merge((yyvsp[-1]), (yyvsp[0]));
}
-#line 3812 "awkgram.c" /* yacc.c:1646 */
+#line 3830 "awkgram.c" /* yacc.c:1646 */
break;
case 169:
-#line 1738 "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 */
@@ -3826,11 +3844,11 @@ regular_print:
sub_counter++; /* count # of dimensions */
(yyval) = (yyvsp[0]);
}
-#line 3830 "awkgram.c" /* yacc.c:1646 */
+#line 3848 "awkgram.c" /* yacc.c:1646 */
break;
case 170:
-#line 1755 "awkgram.y" /* yacc.c:1646 */
+#line 1773 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *t = (yyvsp[-1]);
if ((yyvsp[-1]) == NULL) {
@@ -3844,31 +3862,31 @@ regular_print:
(yyvsp[0])->sub_count = count_expressions(&t, false);
(yyval) = list_append(t, (yyvsp[0]));
}
-#line 3848 "awkgram.c" /* yacc.c:1646 */
+#line 3866 "awkgram.c" /* yacc.c:1646 */
break;
case 171:
-#line 1772 "awkgram.y" /* yacc.c:1646 */
+#line 1790 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3854 "awkgram.c" /* yacc.c:1646 */
+#line 3872 "awkgram.c" /* yacc.c:1646 */
break;
case 172:
-#line 1774 "awkgram.y" /* yacc.c:1646 */
+#line 1792 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = list_merge((yyvsp[-1]), (yyvsp[0]));
}
-#line 3862 "awkgram.c" /* yacc.c:1646 */
+#line 3880 "awkgram.c" /* yacc.c:1646 */
break;
case 173:
-#line 1781 "awkgram.y" /* yacc.c:1646 */
+#line 1799 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[-1]); }
-#line 3868 "awkgram.c" /* yacc.c:1646 */
+#line 3886 "awkgram.c" /* yacc.c:1646 */
break;
case 174:
-#line 1786 "awkgram.y" /* yacc.c:1646 */
+#line 1804 "awkgram.y" /* yacc.c:1646 */
{
char *var_name = (yyvsp[0])->lextok;
@@ -3876,22 +3894,22 @@ regular_print:
(yyvsp[0])->memory = variable((yyvsp[0])->source_line, var_name, Node_var_new);
(yyval) = list_create((yyvsp[0]));
}
-#line 3880 "awkgram.c" /* yacc.c:1646 */
+#line 3898 "awkgram.c" /* yacc.c:1646 */
break;
case 175:
-#line 1794 "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 3891 "awkgram.c" /* yacc.c:1646 */
+#line 3909 "awkgram.c" /* yacc.c:1646 */
break;
case 176:
-#line 1804 "awkgram.y" /* yacc.c:1646 */
+#line 1822 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *ip = (yyvsp[0])->nexti;
if (ip->opcode == Op_push
@@ -3903,73 +3921,73 @@ regular_print:
} else
(yyval) = (yyvsp[0]);
}
-#line 3907 "awkgram.c" /* yacc.c:1646 */
+#line 3925 "awkgram.c" /* yacc.c:1646 */
break;
case 177:
-#line 1816 "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 3917 "awkgram.c" /* yacc.c:1646 */
+#line 3935 "awkgram.c" /* yacc.c:1646 */
break;
case 178:
-#line 1825 "awkgram.y" /* yacc.c:1646 */
+#line 1843 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[0])->opcode = Op_postincrement;
}
-#line 3925 "awkgram.c" /* yacc.c:1646 */
+#line 3943 "awkgram.c" /* yacc.c:1646 */
break;
case 179:
-#line 1829 "awkgram.y" /* yacc.c:1646 */
+#line 1847 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[0])->opcode = Op_postdecrement;
}
-#line 3933 "awkgram.c" /* yacc.c:1646 */
+#line 3951 "awkgram.c" /* yacc.c:1646 */
break;
case 180:
-#line 1832 "awkgram.y" /* yacc.c:1646 */
+#line 1850 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3939 "awkgram.c" /* yacc.c:1646 */
+#line 3957 "awkgram.c" /* yacc.c:1646 */
break;
case 182:
-#line 1840 "awkgram.y" /* yacc.c:1646 */
+#line 1858 "awkgram.y" /* yacc.c:1646 */
{ yyerrok; }
-#line 3945 "awkgram.c" /* yacc.c:1646 */
+#line 3963 "awkgram.c" /* yacc.c:1646 */
break;
case 183:
-#line 1844 "awkgram.y" /* yacc.c:1646 */
+#line 1862 "awkgram.y" /* yacc.c:1646 */
{ yyerrok; }
-#line 3951 "awkgram.c" /* yacc.c:1646 */
+#line 3969 "awkgram.c" /* yacc.c:1646 */
break;
case 186:
-#line 1853 "awkgram.y" /* yacc.c:1646 */
+#line 1871 "awkgram.y" /* yacc.c:1646 */
{ yyerrok; }
-#line 3957 "awkgram.c" /* yacc.c:1646 */
+#line 3975 "awkgram.c" /* yacc.c:1646 */
break;
case 187:
-#line 1857 "awkgram.y" /* yacc.c:1646 */
+#line 1875 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); yyerrok; }
-#line 3963 "awkgram.c" /* yacc.c:1646 */
+#line 3981 "awkgram.c" /* yacc.c:1646 */
break;
case 188:
-#line 1861 "awkgram.y" /* yacc.c:1646 */
+#line 1879 "awkgram.y" /* yacc.c:1646 */
{ yyerrok; }
-#line 3969 "awkgram.c" /* yacc.c:1646 */
+#line 3987 "awkgram.c" /* yacc.c:1646 */
break;
-#line 3973 "awkgram.c" /* yacc.c:1646 */
+#line 3991 "awkgram.c" /* yacc.c:1646 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@@ -4197,7 +4215,7 @@ yyreturn:
#endif
return yyresult;
}
-#line 1863 "awkgram.y" /* yacc.c:1906 */
+#line 1881 "awkgram.y" /* yacc.c:1906 */
struct token {
@@ -4736,6 +4754,9 @@ parse_program(INSTRUCTION **pcode)
if (ret == 0) /* avoid spurious warning if parser aborted with YYABORT */
check_funcs();
+ if (! check_param_names())
+ errcount++;
+
if (args_array == NULL)
emalloc(args_array, NODE **, (max_args + 2) * sizeof(NODE *), "parse_program");
else
@@ -5665,6 +5686,7 @@ retry:
return lasttok = NEWLINE;
case '@':
+ at_seen = true;
return lasttok = '@';
case '\\':
diff --git a/awkgram.y b/awkgram.y
index 5e3bade9..91ebe3b3 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -87,6 +87,7 @@ static int one_line_close(int fd);
static void split_comment(void);
static void check_comment(void);
+static bool at_seen = false;
static bool want_source = false;
static bool want_regexp = false; /* lexical scanning kludge */
static char *in_function; /* parsing kludge */
@@ -250,11 +251,13 @@ rule
| '@' LEX_INCLUDE source statement_term
{
want_source = false;
+ at_seen = false;
yyerrok;
}
| '@' LEX_LOAD library statement_term
{
want_source = false;
+ at_seen = false;
yyerrok;
}
;
@@ -409,7 +412,10 @@ func_name
YYABORT;
}
| '@' LEX_EVAL
- { $$ = $2; }
+ {
+ $$ = $2;
+ at_seen = false;
+ }
;
lex_builtin
@@ -1690,12 +1696,24 @@ func_call
*/
$$ = list_prepend($2, t);
+ at_seen = false;
}
;
direct_func_call
: FUNC_CALL '(' opt_expression_list r_paren
{
+ NODE *n;
+
+ if (! at_seen) {
+ n = lookup($1->func_name);
+ if (n != NULL && n->type != Node_func
+ && n->type != Node_ext_func && n->type != Node_old_ext_func) {
+ error_ln($1->source_line,
+ _("attempt to use non-function `%s' in function call"),
+ $1->func_name);
+ }
+ }
param_sanity($3);
$1->opcode = Op_func_call;
$1->func_body = NULL;
@@ -2398,6 +2416,9 @@ parse_program(INSTRUCTION **pcode)
if (ret == 0) /* avoid spurious warning if parser aborted with YYABORT */
check_funcs();
+ if (! check_param_names())
+ errcount++;
+
if (args_array == NULL)
emalloc(args_array, NODE **, (max_args + 2) * sizeof(NODE *), "parse_program");
else
@@ -3327,6 +3348,7 @@ retry:
return lasttok = NEWLINE;
case '@':
+ at_seen = true;
return lasttok = '@';
case '\\':
diff --git a/doc/ChangeLog b/doc/ChangeLog
index c91e2d4a..27dca3dc 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-30 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in: Document POSIX requirement that function parameters
+ cannot have the same name as a function. Fix indirectcall example.
+
2015-01-27 Arnold D. Robbins <arnold@skeeve.com>
* gawktexi.in: O'Reilly fixes.
diff --git a/doc/gawk.info b/doc/gawk.info
index caa2ead8..1c74fc99 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -13489,11 +13489,13 @@ the argument names are used to hold the argument values given in the
call.
A function cannot have two parameters with the same name, nor may it
-have a parameter with the same name as the function itself. In
-addition, according to the POSIX standard, function parameters cannot
-have the same name as one of the special predefined variables (*note
-Built-in Variables::). Not all versions of `awk' enforce this
-restriction.
+have a parameter with the same name as the function itself.
+
+ CAUTION: According to the POSIX standard, function parameters
+ cannot have the same name as one of the special predefined
+ variables (*note Built-in Variables::), nor may a function
+ parameter have the same name as another function. Not all
+ versions of `awk' enforce these restrictions.
Local variables act like the empty string if referenced where a
string value is required, and like zero if referenced where a numeric
@@ -14095,13 +14097,13 @@ using indirect function calls:
# average --- return the average of the values in fields $first - $last
- function average(first, last, sum, i)
+ function average(first, last, the_sum, i)
{
- sum = 0;
+ the_sum = 0;
for (i = first; i <= last; i++)
- sum += $i
+ the_sum += $i
- return sum / (last - first + 1)
+ return the_sum / (last - first + 1)
}
# sum --- return the sum of the values in fields $first - $last
@@ -32303,7 +32305,7 @@ Index
* common extensions, \x escape sequence: Escape Sequences. (line 61)
* common extensions, BINMODE variable: PC Using. (line 33)
* common extensions, delete to delete entire arrays: Delete. (line 39)
-* common extensions, func keyword: Definition Syntax. (line 93)
+* common extensions, func keyword: Definition Syntax. (line 95)
* common extensions, length() applied to an array: String Functions.
(line 201)
* common extensions, RS as a regexp: gawk split records. (line 6)
@@ -32825,7 +32827,7 @@ Index
* extensions, common, BINMODE variable: PC Using. (line 33)
* extensions, common, delete to delete entire arrays: Delete. (line 39)
* extensions, common, fflush() function: I/O Functions. (line 43)
-* extensions, common, func keyword: Definition Syntax. (line 93)
+* extensions, common, func keyword: Definition Syntax. (line 95)
* extensions, common, length() applied to an array: String Functions.
(line 201)
* extensions, common, RS as a regexp: gawk split records. (line 6)
@@ -33042,7 +33044,7 @@ Index
* functions, library, user database, reading: Passwd Functions.
(line 6)
* functions, names of: Definition Syntax. (line 23)
-* functions, recursive: Definition Syntax. (line 83)
+* functions, recursive: Definition Syntax. (line 85)
* functions, string-translation: I18N Functions. (line 6)
* functions, undefined: Pass By Value/Reference.
(line 68)
@@ -33769,7 +33771,7 @@ Index
(line 65)
* portability, deleting array elements: Delete. (line 56)
* portability, example programs: Library Functions. (line 42)
-* portability, functions, defining: Definition Syntax. (line 109)
+* portability, functions, defining: Definition Syntax. (line 111)
* portability, gawk: New Ports. (line 6)
* portability, gettext library and: Explaining gettext. (line 11)
* portability, internationalization and: I18N Portability. (line 6)
@@ -33814,7 +33816,7 @@ Index
* POSIX awk, field separators and <1>: Full Line Fields. (line 16)
* POSIX awk, field separators and: Fields. (line 6)
* POSIX awk, FS variable and: User-modified. (line 60)
-* POSIX awk, function keyword in: Definition Syntax. (line 93)
+* POSIX awk, function keyword in: Definition Syntax. (line 95)
* POSIX awk, functions and, gsub()/sub(): Gory Details. (line 90)
* POSIX awk, functions and, length(): String Functions. (line 180)
* POSIX awk, GNU long options and: Options. (line 15)
@@ -33907,7 +33909,7 @@ Index
* programming conventions, functions, calling: Calling Built-in.
(line 10)
* programming conventions, functions, writing: Definition Syntax.
- (line 65)
+ (line 67)
* programming conventions, gawk extensions: Internal File Ops.
(line 45)
* programming conventions, private variable names: Library Names.
@@ -33976,7 +33978,7 @@ Index
* records, splitting input into: Records. (line 6)
* records, terminating: awk split records. (line 125)
* records, treating files as: gawk split records. (line 93)
-* recursive functions: Definition Syntax. (line 83)
+* recursive functions: Definition Syntax. (line 85)
* redirect gawk output, in debugger: Debugger Info. (line 72)
* redirection of input: Getline/File. (line 6)
* redirection of output: Redirection. (line 6)
@@ -34145,7 +34147,7 @@ Index
* set directory of message catalogs: I18N Functions. (line 12)
* set watchpoint: Viewing And Changing Data.
(line 67)
-* shadowing of variable values: Definition Syntax. (line 71)
+* shadowing of variable values: Definition Syntax. (line 73)
* shell quoting, rules for: Quoting. (line 6)
* shells, piping commands into: Redirection. (line 136)
* shells, quoting: Using Shell Variables.
@@ -34519,7 +34521,7 @@ Index
* variables, predefined conveying information: Auto-set. (line 6)
* variables, private: Library Names. (line 11)
* variables, setting: Options. (line 32)
-* variables, shadowing: Definition Syntax. (line 71)
+* variables, shadowing: Definition Syntax. (line 73)
* variables, types of: Assignment Ops. (line 40)
* variables, types of, comparison expressions and: Typing and Comparison.
(line 9)
@@ -34876,303 +34878,303 @@ Node: Type Functions564425
Node: I18N Functions565576
Node: User-defined567221
Node: Definition Syntax568026
-Ref: Definition Syntax-Footnote-1573433
-Node: Function Example573504
-Ref: Function Example-Footnote-1576423
-Node: Function Caveats576445
-Node: Calling A Function576963
-Node: Variable Scope577921
-Node: Pass By Value/Reference580909
-Node: Return Statement584404
-Node: Dynamic Typing587385
-Node: Indirect Calls588314
-Ref: Indirect Calls-Footnote-1599616
-Node: Functions Summary599744
-Node: Library Functions602446
-Ref: Library Functions-Footnote-1606055
-Ref: Library Functions-Footnote-2606198
-Node: Library Names606369
-Ref: Library Names-Footnote-1609823
-Ref: Library Names-Footnote-2610046
-Node: General Functions610132
-Node: Strtonum Function611235
-Node: Assert Function614257
-Node: Round Function617581
-Node: Cliff Random Function619122
-Node: Ordinal Functions620138
-Ref: Ordinal Functions-Footnote-1623201
-Ref: Ordinal Functions-Footnote-2623453
-Node: Join Function623664
-Ref: Join Function-Footnote-1625433
-Node: Getlocaltime Function625633
-Node: Readfile Function629377
-Node: Shell Quoting631347
-Node: Data File Management632748
-Node: Filetrans Function633380
-Node: Rewind Function637436
-Node: File Checking638823
-Ref: File Checking-Footnote-1640155
-Node: Empty Files640356
-Node: Ignoring Assigns642335
-Node: Getopt Function643886
-Ref: Getopt Function-Footnote-1655348
-Node: Passwd Functions655548
-Ref: Passwd Functions-Footnote-1664385
-Node: Group Functions664473
-Ref: Group Functions-Footnote-1672367
-Node: Walking Arrays672580
-Node: Library Functions Summary674183
-Node: Library Exercises675584
-Node: Sample Programs676864
-Node: Running Examples677634
-Node: Clones678362
-Node: Cut Program679586
-Node: Egrep Program689305
-Ref: Egrep Program-Footnote-1696803
-Node: Id Program696913
-Node: Split Program700558
-Ref: Split Program-Footnote-1704006
-Node: Tee Program704134
-Node: Uniq Program706923
-Node: Wc Program714342
-Ref: Wc Program-Footnote-1718592
-Node: Miscellaneous Programs718686
-Node: Dupword Program719899
-Node: Alarm Program721930
-Node: Translate Program726734
-Ref: Translate Program-Footnote-1731299
-Node: Labels Program731569
-Ref: Labels Program-Footnote-1734920
-Node: Word Sorting735004
-Node: History Sorting739075
-Node: Extract Program740911
-Node: Simple Sed748436
-Node: Igawk Program751504
-Ref: Igawk Program-Footnote-1765828
-Ref: Igawk Program-Footnote-2766029
-Ref: Igawk Program-Footnote-3766151
-Node: Anagram Program766266
-Node: Signature Program769323
-Node: Programs Summary770570
-Node: Programs Exercises771763
-Ref: Programs Exercises-Footnote-1775894
-Node: Advanced Features775985
-Node: Nondecimal Data777933
-Node: Array Sorting779523
-Node: Controlling Array Traversal780220
-Ref: Controlling Array Traversal-Footnote-1788553
-Node: Array Sorting Functions788671
-Ref: Array Sorting Functions-Footnote-1792560
-Node: Two-way I/O792756
-Ref: Two-way I/O-Footnote-1797701
-Ref: Two-way I/O-Footnote-2797887
-Node: TCP/IP Networking797969
-Node: Profiling800842
-Node: Advanced Features Summary809119
-Node: Internationalization811052
-Node: I18N and L10N812532
-Node: Explaining gettext813218
-Ref: Explaining gettext-Footnote-1818243
-Ref: Explaining gettext-Footnote-2818427
-Node: Programmer i18n818592
-Ref: Programmer i18n-Footnote-1823458
-Node: Translator i18n823507
-Node: String Extraction824301
-Ref: String Extraction-Footnote-1825432
-Node: Printf Ordering825518
-Ref: Printf Ordering-Footnote-1828304
-Node: I18N Portability828368
-Ref: I18N Portability-Footnote-1830823
-Node: I18N Example830886
-Ref: I18N Example-Footnote-1833689
-Node: Gawk I18N833761
-Node: I18N Summary834399
-Node: Debugger835738
-Node: Debugging836760
-Node: Debugging Concepts837201
-Node: Debugging Terms839054
-Node: Awk Debugging841626
-Node: Sample Debugging Session842520
-Node: Debugger Invocation843040
-Node: Finding The Bug844424
-Node: List of Debugger Commands850899
-Node: Breakpoint Control852232
-Node: Debugger Execution Control855928
-Node: Viewing And Changing Data859292
-Node: Execution Stack862670
-Node: Debugger Info864307
-Node: Miscellaneous Debugger Commands868324
-Node: Readline Support873353
-Node: Limitations874245
-Node: Debugging Summary876359
-Node: Arbitrary Precision Arithmetic877527
-Node: Computer Arithmetic878943
-Ref: table-numeric-ranges882541
-Ref: Computer Arithmetic-Footnote-1883400
-Node: Math Definitions883457
-Ref: table-ieee-formats886745
-Ref: Math Definitions-Footnote-1887349
-Node: MPFR features887454
-Node: FP Math Caution889125
-Ref: FP Math Caution-Footnote-1890175
-Node: Inexactness of computations890544
-Node: Inexact representation891503
-Node: Comparing FP Values892860
-Node: Errors accumulate893942
-Node: Getting Accuracy895375
-Node: Try To Round898037
-Node: Setting precision898936
-Ref: table-predefined-precision-strings899620
-Node: Setting the rounding mode901409
-Ref: table-gawk-rounding-modes901773
-Ref: Setting the rounding mode-Footnote-1905228
-Node: Arbitrary Precision Integers905407
-Ref: Arbitrary Precision Integers-Footnote-1910307
-Node: POSIX Floating Point Problems910456
-Ref: POSIX Floating Point Problems-Footnote-1914329
-Node: Floating point summary914367
-Node: Dynamic Extensions916561
-Node: Extension Intro918113
-Node: Plugin License919379
-Node: Extension Mechanism Outline920176
-Ref: figure-load-extension920604
-Ref: figure-register-new-function922084
-Ref: figure-call-new-function923088
-Node: Extension API Description925074
-Node: Extension API Functions Introduction926524
-Node: General Data Types931348
-Ref: General Data Types-Footnote-1937087
-Node: Memory Allocation Functions937386
-Ref: Memory Allocation Functions-Footnote-1940225
-Node: Constructor Functions940321
-Node: Registration Functions942055
-Node: Extension Functions942740
-Node: Exit Callback Functions945037
-Node: Extension Version String946285
-Node: Input Parsers946950
-Node: Output Wrappers956829
-Node: Two-way processors961344
-Node: Printing Messages963548
-Ref: Printing Messages-Footnote-1964624
-Node: Updating `ERRNO'964776
-Node: Requesting Values965516
-Ref: table-value-types-returned966244
-Node: Accessing Parameters967201
-Node: Symbol Table Access968432
-Node: Symbol table by name968946
-Node: Symbol table by cookie970927
-Ref: Symbol table by cookie-Footnote-1975071
-Node: Cached values975134
-Ref: Cached values-Footnote-1978633
-Node: Array Manipulation978724
-Ref: Array Manipulation-Footnote-1979822
-Node: Array Data Types979859
-Ref: Array Data Types-Footnote-1982514
-Node: Array Functions982606
-Node: Flattening Arrays986460
-Node: Creating Arrays993352
-Node: Extension API Variables998123
-Node: Extension Versioning998759
-Node: Extension API Informational Variables1000660
-Node: Extension API Boilerplate1001725
-Node: Finding Extensions1005534
-Node: Extension Example1006094
-Node: Internal File Description1006866
-Node: Internal File Ops1010933
-Ref: Internal File Ops-Footnote-11022603
-Node: Using Internal File Ops1022743
-Ref: Using Internal File Ops-Footnote-11025126
-Node: Extension Samples1025399
-Node: Extension Sample File Functions1026925
-Node: Extension Sample Fnmatch1034563
-Node: Extension Sample Fork1036054
-Node: Extension Sample Inplace1037269
-Node: Extension Sample Ord1038944
-Node: Extension Sample Readdir1039780
-Ref: table-readdir-file-types1040656
-Node: Extension Sample Revout1041467
-Node: Extension Sample Rev2way1042057
-Node: Extension Sample Read write array1042797
-Node: Extension Sample Readfile1044737
-Node: Extension Sample Time1045832
-Node: Extension Sample API Tests1047181
-Node: gawkextlib1047672
-Node: Extension summary1050330
-Node: Extension Exercises1054019
-Node: Language History1054741
-Node: V7/SVR3.11056397
-Node: SVR41058578
-Node: POSIX1060023
-Node: BTL1061412
-Node: POSIX/GNU1062146
-Node: Feature History1067770
-Node: Common Extensions1080868
-Node: Ranges and Locales1082192
-Ref: Ranges and Locales-Footnote-11086810
-Ref: Ranges and Locales-Footnote-21086837
-Ref: Ranges and Locales-Footnote-31087071
-Node: Contributors1087292
-Node: History summary1092833
-Node: Installation1094203
-Node: Gawk Distribution1095149
-Node: Getting1095633
-Node: Extracting1096456
-Node: Distribution contents1098091
-Node: Unix Installation1104156
-Node: Quick Installation1104839
-Node: Shell Startup Files1107250
-Node: Additional Configuration Options1108329
-Node: Configuration Philosophy1110068
-Node: Non-Unix Installation1112437
-Node: PC Installation1112895
-Node: PC Binary Installation1114214
-Node: PC Compiling1116062
-Ref: PC Compiling-Footnote-11119083
-Node: PC Testing1119192
-Node: PC Using1120368
-Node: Cygwin1124483
-Node: MSYS1125306
-Node: VMS Installation1125806
-Node: VMS Compilation1126598
-Ref: VMS Compilation-Footnote-11127820
-Node: VMS Dynamic Extensions1127878
-Node: VMS Installation Details1129562
-Node: VMS Running1131814
-Node: VMS GNV1134650
-Node: VMS Old Gawk1135384
-Node: Bugs1135854
-Node: Other Versions1139737
-Node: Installation summary1146161
-Node: Notes1147217
-Node: Compatibility Mode1148082
-Node: Additions1148864
-Node: Accessing The Source1149789
-Node: Adding Code1151224
-Node: New Ports1157381
-Node: Derived Files1161863
-Ref: Derived Files-Footnote-11167338
-Ref: Derived Files-Footnote-21167372
-Ref: Derived Files-Footnote-31167968
-Node: Future Extensions1168082
-Node: Implementation Limitations1168688
-Node: Extension Design1169936
-Node: Old Extension Problems1171090
-Ref: Old Extension Problems-Footnote-11172607
-Node: Extension New Mechanism Goals1172664
-Ref: Extension New Mechanism Goals-Footnote-11176024
-Node: Extension Other Design Decisions1176213
-Node: Extension Future Growth1178321
-Node: Old Extension Mechanism1179157
-Node: Notes summary1180919
-Node: Basic Concepts1182105
-Node: Basic High Level1182786
-Ref: figure-general-flow1183058
-Ref: figure-process-flow1183657
-Ref: Basic High Level-Footnote-11186886
-Node: Basic Data Typing1187071
-Node: Glossary1190399
-Node: Copying1222328
-Node: GNU Free Documentation License1259884
-Node: Index1285020
+Ref: Definition Syntax-Footnote-1573525
+Node: Function Example573596
+Ref: Function Example-Footnote-1576515
+Node: Function Caveats576537
+Node: Calling A Function577055
+Node: Variable Scope578013
+Node: Pass By Value/Reference581001
+Node: Return Statement584496
+Node: Dynamic Typing587477
+Node: Indirect Calls588406
+Ref: Indirect Calls-Footnote-1599724
+Node: Functions Summary599852
+Node: Library Functions602554
+Ref: Library Functions-Footnote-1606163
+Ref: Library Functions-Footnote-2606306
+Node: Library Names606477
+Ref: Library Names-Footnote-1609931
+Ref: Library Names-Footnote-2610154
+Node: General Functions610240
+Node: Strtonum Function611343
+Node: Assert Function614365
+Node: Round Function617689
+Node: Cliff Random Function619230
+Node: Ordinal Functions620246
+Ref: Ordinal Functions-Footnote-1623309
+Ref: Ordinal Functions-Footnote-2623561
+Node: Join Function623772
+Ref: Join Function-Footnote-1625541
+Node: Getlocaltime Function625741
+Node: Readfile Function629485
+Node: Shell Quoting631455
+Node: Data File Management632856
+Node: Filetrans Function633488
+Node: Rewind Function637544
+Node: File Checking638931
+Ref: File Checking-Footnote-1640263
+Node: Empty Files640464
+Node: Ignoring Assigns642443
+Node: Getopt Function643994
+Ref: Getopt Function-Footnote-1655456
+Node: Passwd Functions655656
+Ref: Passwd Functions-Footnote-1664493
+Node: Group Functions664581
+Ref: Group Functions-Footnote-1672475
+Node: Walking Arrays672688
+Node: Library Functions Summary674291
+Node: Library Exercises675692
+Node: Sample Programs676972
+Node: Running Examples677742
+Node: Clones678470
+Node: Cut Program679694
+Node: Egrep Program689413
+Ref: Egrep Program-Footnote-1696911
+Node: Id Program697021
+Node: Split Program700666
+Ref: Split Program-Footnote-1704114
+Node: Tee Program704242
+Node: Uniq Program707031
+Node: Wc Program714450
+Ref: Wc Program-Footnote-1718700
+Node: Miscellaneous Programs718794
+Node: Dupword Program720007
+Node: Alarm Program722038
+Node: Translate Program726842
+Ref: Translate Program-Footnote-1731407
+Node: Labels Program731677
+Ref: Labels Program-Footnote-1735028
+Node: Word Sorting735112
+Node: History Sorting739183
+Node: Extract Program741019
+Node: Simple Sed748544
+Node: Igawk Program751612
+Ref: Igawk Program-Footnote-1765936
+Ref: Igawk Program-Footnote-2766137
+Ref: Igawk Program-Footnote-3766259
+Node: Anagram Program766374
+Node: Signature Program769431
+Node: Programs Summary770678
+Node: Programs Exercises771871
+Ref: Programs Exercises-Footnote-1776002
+Node: Advanced Features776093
+Node: Nondecimal Data778041
+Node: Array Sorting779631
+Node: Controlling Array Traversal780328
+Ref: Controlling Array Traversal-Footnote-1788661
+Node: Array Sorting Functions788779
+Ref: Array Sorting Functions-Footnote-1792668
+Node: Two-way I/O792864
+Ref: Two-way I/O-Footnote-1797809
+Ref: Two-way I/O-Footnote-2797995
+Node: TCP/IP Networking798077
+Node: Profiling800950
+Node: Advanced Features Summary809227
+Node: Internationalization811160
+Node: I18N and L10N812640
+Node: Explaining gettext813326
+Ref: Explaining gettext-Footnote-1818351
+Ref: Explaining gettext-Footnote-2818535
+Node: Programmer i18n818700
+Ref: Programmer i18n-Footnote-1823566
+Node: Translator i18n823615
+Node: String Extraction824409
+Ref: String Extraction-Footnote-1825540
+Node: Printf Ordering825626
+Ref: Printf Ordering-Footnote-1828412
+Node: I18N Portability828476
+Ref: I18N Portability-Footnote-1830931
+Node: I18N Example830994
+Ref: I18N Example-Footnote-1833797
+Node: Gawk I18N833869
+Node: I18N Summary834507
+Node: Debugger835846
+Node: Debugging836868
+Node: Debugging Concepts837309
+Node: Debugging Terms839162
+Node: Awk Debugging841734
+Node: Sample Debugging Session842628
+Node: Debugger Invocation843148
+Node: Finding The Bug844532
+Node: List of Debugger Commands851007
+Node: Breakpoint Control852340
+Node: Debugger Execution Control856036
+Node: Viewing And Changing Data859400
+Node: Execution Stack862778
+Node: Debugger Info864415
+Node: Miscellaneous Debugger Commands868432
+Node: Readline Support873461
+Node: Limitations874353
+Node: Debugging Summary876467
+Node: Arbitrary Precision Arithmetic877635
+Node: Computer Arithmetic879051
+Ref: table-numeric-ranges882649
+Ref: Computer Arithmetic-Footnote-1883508
+Node: Math Definitions883565
+Ref: table-ieee-formats886853
+Ref: Math Definitions-Footnote-1887457
+Node: MPFR features887562
+Node: FP Math Caution889233
+Ref: FP Math Caution-Footnote-1890283
+Node: Inexactness of computations890652
+Node: Inexact representation891611
+Node: Comparing FP Values892968
+Node: Errors accumulate894050
+Node: Getting Accuracy895483
+Node: Try To Round898145
+Node: Setting precision899044
+Ref: table-predefined-precision-strings899728
+Node: Setting the rounding mode901517
+Ref: table-gawk-rounding-modes901881
+Ref: Setting the rounding mode-Footnote-1905336
+Node: Arbitrary Precision Integers905515
+Ref: Arbitrary Precision Integers-Footnote-1910415
+Node: POSIX Floating Point Problems910564
+Ref: POSIX Floating Point Problems-Footnote-1914437
+Node: Floating point summary914475
+Node: Dynamic Extensions916669
+Node: Extension Intro918221
+Node: Plugin License919487
+Node: Extension Mechanism Outline920284
+Ref: figure-load-extension920712
+Ref: figure-register-new-function922192
+Ref: figure-call-new-function923196
+Node: Extension API Description925182
+Node: Extension API Functions Introduction926632
+Node: General Data Types931456
+Ref: General Data Types-Footnote-1937195
+Node: Memory Allocation Functions937494
+Ref: Memory Allocation Functions-Footnote-1940333
+Node: Constructor Functions940429
+Node: Registration Functions942163
+Node: Extension Functions942848
+Node: Exit Callback Functions945145
+Node: Extension Version String946393
+Node: Input Parsers947058
+Node: Output Wrappers956937
+Node: Two-way processors961452
+Node: Printing Messages963656
+Ref: Printing Messages-Footnote-1964732
+Node: Updating `ERRNO'964884
+Node: Requesting Values965624
+Ref: table-value-types-returned966352
+Node: Accessing Parameters967309
+Node: Symbol Table Access968540
+Node: Symbol table by name969054
+Node: Symbol table by cookie971035
+Ref: Symbol table by cookie-Footnote-1975179
+Node: Cached values975242
+Ref: Cached values-Footnote-1978741
+Node: Array Manipulation978832
+Ref: Array Manipulation-Footnote-1979930
+Node: Array Data Types979967
+Ref: Array Data Types-Footnote-1982622
+Node: Array Functions982714
+Node: Flattening Arrays986568
+Node: Creating Arrays993460
+Node: Extension API Variables998231
+Node: Extension Versioning998867
+Node: Extension API Informational Variables1000768
+Node: Extension API Boilerplate1001833
+Node: Finding Extensions1005642
+Node: Extension Example1006202
+Node: Internal File Description1006974
+Node: Internal File Ops1011041
+Ref: Internal File Ops-Footnote-11022711
+Node: Using Internal File Ops1022851
+Ref: Using Internal File Ops-Footnote-11025234
+Node: Extension Samples1025507
+Node: Extension Sample File Functions1027033
+Node: Extension Sample Fnmatch1034671
+Node: Extension Sample Fork1036162
+Node: Extension Sample Inplace1037377
+Node: Extension Sample Ord1039052
+Node: Extension Sample Readdir1039888
+Ref: table-readdir-file-types1040764
+Node: Extension Sample Revout1041575
+Node: Extension Sample Rev2way1042165
+Node: Extension Sample Read write array1042905
+Node: Extension Sample Readfile1044845
+Node: Extension Sample Time1045940
+Node: Extension Sample API Tests1047289
+Node: gawkextlib1047780
+Node: Extension summary1050438
+Node: Extension Exercises1054127
+Node: Language History1054849
+Node: V7/SVR3.11056505
+Node: SVR41058686
+Node: POSIX1060131
+Node: BTL1061520
+Node: POSIX/GNU1062254
+Node: Feature History1067878
+Node: Common Extensions1080976
+Node: Ranges and Locales1082300
+Ref: Ranges and Locales-Footnote-11086918
+Ref: Ranges and Locales-Footnote-21086945
+Ref: Ranges and Locales-Footnote-31087179
+Node: Contributors1087400
+Node: History summary1092941
+Node: Installation1094311
+Node: Gawk Distribution1095257
+Node: Getting1095741
+Node: Extracting1096564
+Node: Distribution contents1098199
+Node: Unix Installation1104264
+Node: Quick Installation1104947
+Node: Shell Startup Files1107358
+Node: Additional Configuration Options1108437
+Node: Configuration Philosophy1110176
+Node: Non-Unix Installation1112545
+Node: PC Installation1113003
+Node: PC Binary Installation1114322
+Node: PC Compiling1116170
+Ref: PC Compiling-Footnote-11119191
+Node: PC Testing1119300
+Node: PC Using1120476
+Node: Cygwin1124591
+Node: MSYS1125414
+Node: VMS Installation1125914
+Node: VMS Compilation1126706
+Ref: VMS Compilation-Footnote-11127928
+Node: VMS Dynamic Extensions1127986
+Node: VMS Installation Details1129670
+Node: VMS Running1131922
+Node: VMS GNV1134758
+Node: VMS Old Gawk1135492
+Node: Bugs1135962
+Node: Other Versions1139845
+Node: Installation summary1146269
+Node: Notes1147325
+Node: Compatibility Mode1148190
+Node: Additions1148972
+Node: Accessing The Source1149897
+Node: Adding Code1151332
+Node: New Ports1157489
+Node: Derived Files1161971
+Ref: Derived Files-Footnote-11167446
+Ref: Derived Files-Footnote-21167480
+Ref: Derived Files-Footnote-31168076
+Node: Future Extensions1168190
+Node: Implementation Limitations1168796
+Node: Extension Design1170044
+Node: Old Extension Problems1171198
+Ref: Old Extension Problems-Footnote-11172715
+Node: Extension New Mechanism Goals1172772
+Ref: Extension New Mechanism Goals-Footnote-11176132
+Node: Extension Other Design Decisions1176321
+Node: Extension Future Growth1178429
+Node: Old Extension Mechanism1179265
+Node: Notes summary1181027
+Node: Basic Concepts1182213
+Node: Basic High Level1182894
+Ref: figure-general-flow1183166
+Ref: figure-process-flow1183765
+Ref: Basic High Level-Footnote-11186994
+Node: Basic Data Typing1187179
+Node: Glossary1190507
+Node: Copying1222436
+Node: GNU Free Documentation License1259992
+Node: Index1285128

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index f7640b58..68512c2d 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -19369,10 +19369,15 @@ the call.
A function cannot have two parameters with the same name, nor may it
have a parameter with the same name as the function itself.
-In addition, according to the POSIX standard, function parameters
+
+@quotation CAUTION
+According to the POSIX standard, function parameters
cannot have the same name as one of the special predefined variables
-(@pxref{Built-in Variables}). Not all versions of @command{awk} enforce
-this restriction.
+(@pxref{Built-in Variables}), nor may a function parameter have the
+same name as another function.
+Not all versions of @command{awk} enforce
+these restrictions.
+@end quotation
Local variables act like the empty string if referenced where a string
value is required, and like zero if referenced where a numeric value
@@ -20089,13 +20094,13 @@ using indirect function calls:
@c file eg/prog/indirectcall.awk
# average --- return the average of the values in fields $first - $last
-function average(first, last, sum, i)
+function average(first, last, the_sum, i)
@{
- sum = 0;
+ the_sum = 0;
for (i = first; i <= last; i++)
- sum += $i
+ the_sum += $i
- return sum / (last - first + 1)
+ return the_sum / (last - first + 1)
@}
# sum --- return the sum of the values in fields $first - $last
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index 1e7a5421..f3805887 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -18490,10 +18490,15 @@ the call.
A function cannot have two parameters with the same name, nor may it
have a parameter with the same name as the function itself.
-In addition, according to the POSIX standard, function parameters
+
+@quotation CAUTION
+According to the POSIX standard, function parameters
cannot have the same name as one of the special predefined variables
-(@pxref{Built-in Variables}). Not all versions of @command{awk} enforce
-this restriction.
+(@pxref{Built-in Variables}), nor may a function parameter have the
+same name as another function.
+Not all versions of @command{awk} enforce
+these restrictions.
+@end quotation
Local variables act like the empty string if referenced where a string
value is required, and like zero if referenced where a numeric value
@@ -19210,13 +19215,13 @@ using indirect function calls:
@c file eg/prog/indirectcall.awk
# average --- return the average of the values in fields $first - $last
-function average(first, last, sum, i)
+function average(first, last, the_sum, i)
@{
- sum = 0;
+ the_sum = 0;
for (i = first; i <= last; i++)
- sum += $i
+ the_sum += $i
- return sum / (last - first + 1)
+ return the_sum / (last - first + 1)
@}
# sum --- return the sum of the values in fields $first - $last
diff --git a/symbol.c b/symbol.c
index 23e04c03..552c111e 100644
--- a/symbol.c
+++ b/symbol.c
@@ -625,6 +625,61 @@ load_symbols()
unref(array);
}
+/* check_param_names --- make sure no parameter is the name of a function */
+
+bool
+check_param_names(void)
+{
+ int i, j, k;
+ NODE **list;
+ NODE *f;
+ long max;
+ bool result = true;
+
+ max = func_table->table_size * 2;
+
+ /*
+ * assoc_list() returns an array with two elements per awk array
+ * element. Elements i and i+1 in the C array represent the key
+ * and value of element j in the awk array. Thus the loops use += 2
+ * to go through the awk array.
+ *
+ * In this case, the name is in list[i], and the function is
+ * in list[i+1]. Just what we need.
+ */
+
+ list = assoc_list(func_table, "@unsorted", ASORTI);
+
+ /*
+ * You want linear searches?
+ * Have we got linear searches!
+ */
+ for (i = 0; i < max; i += 2) {
+ f = list[i+1];
+ if (f->type == Node_builtin_func || f->param_cnt == 0)
+ continue;
+
+ /* loop over each param in function i */
+ for (j = 0; j < f->param_cnt; j++) {
+ /* compare to function names */
+ for (k = 0; k < max; k += 2) {
+ if (k == i)
+ continue;
+ if (strcmp(f->fparms[j].param, list[k]->stptr) == 0) {
+ error(
+ _("function `%s': can't use function `%s' as a parameter name"),
+ list[i]->stptr,
+ list[k]->stptr);
+ result = false;
+ }
+ }
+ }
+ }
+
+ efree(list);
+ return result;
+}
+
#define pool_size d.dl
#define freei x.xi
static INSTRUCTION *pool_list;
diff --git a/test/ChangeLog b/test/ChangeLog
index 19105027..ac031426 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,11 @@
+2015-01-30 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Makefile.in (callparam, paramasfunc1, paramasfunc2): New tests.
+ * callparam.awk, callparam.ok: New files.
+ * paramasfunc1.awk, paramasfunc1.ok: New files.
+ * paramasfunc2.awk, paramasfunc2.ok: New files.
+ * exit.sh, indirectcall.awk: Update after code change.
+
2015-01-19 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am (profile8): Actually add the test and the files.
diff --git a/test/Makefile.am b/test/Makefile.am
index 8f501b56..a3fe1beb 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -132,6 +132,8 @@ EXTRA_DIST = \
beginfile2.ok \
beginfile2.sh \
binmode1.ok \
+ callparam.awk \
+ callparam.ok \
charasbytes.awk \
charasbytes.in \
charasbytes.ok \
@@ -642,6 +644,10 @@ EXTRA_DIST = \
out1.ok \
out2.ok \
out3.ok \
+ paramasfunc1.awk \
+ paramasfunc1.ok \
+ paramasfunc2.awk \
+ paramasfunc2.ok \
paramdup.awk \
paramdup.ok \
paramres.awk \
@@ -987,7 +993,7 @@ BASIC_TESTS = \
arynocls aryprm1 aryprm2 aryprm3 aryprm4 aryprm5 aryprm6 aryprm7 \
aryprm8 arysubnm asgext awkpath \
back89 backgsub badassign1 badbuild \
- childin clobber closebad clsflnam compare compare2 concat1 concat2 \
+ callparam childin clobber closebad clsflnam compare compare2 concat1 concat2 \
concat3 concat4 convfmt \
datanonl defref delargv delarpm2 delarprm delfunc dfamb1 dfastress dynlj \
eofsplit exit2 exitval1 exitval2 \
@@ -1005,6 +1011,7 @@ BASIC_TESTS = \
nlinstr nlstrina noeffect nofile nofmtch noloop1 noloop2 nonl \
noparms nors nulrsend numindex numsubstr \
octsub ofmt ofmta ofmtbig ofmtfidl ofmts ofs1 onlynl opasnidx opasnslf \
+ paramasfunc1 paramasfunc2 \
paramdup paramres paramtyp paramuninitglobal parse1 parsefld parseme \
pcntplus posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \
prt1eval prtoeval \
diff --git a/test/Makefile.in b/test/Makefile.in
index 4660de76..57d28cac 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -389,6 +389,8 @@ EXTRA_DIST = \
beginfile2.ok \
beginfile2.sh \
binmode1.ok \
+ callparam.awk \
+ callparam.ok \
charasbytes.awk \
charasbytes.in \
charasbytes.ok \
@@ -899,6 +901,10 @@ EXTRA_DIST = \
out1.ok \
out2.ok \
out3.ok \
+ paramasfunc1.awk \
+ paramasfunc1.ok \
+ paramasfunc2.awk \
+ paramasfunc2.ok \
paramdup.awk \
paramdup.ok \
paramres.awk \
@@ -1243,7 +1249,7 @@ BASIC_TESTS = \
arynocls aryprm1 aryprm2 aryprm3 aryprm4 aryprm5 aryprm6 aryprm7 \
aryprm8 arysubnm asgext awkpath \
back89 backgsub badassign1 badbuild \
- childin clobber closebad clsflnam compare compare2 concat1 concat2 \
+ callparam childin clobber closebad clsflnam compare compare2 concat1 concat2 \
concat3 concat4 convfmt \
datanonl defref delargv delarpm2 delarprm delfunc dfamb1 dfastress dynlj \
eofsplit exit2 exitval1 exitval2 \
@@ -1261,6 +1267,7 @@ BASIC_TESTS = \
nlinstr nlstrina noeffect nofile nofmtch noloop1 noloop2 nonl \
noparms nors nulrsend numindex numsubstr \
octsub ofmt ofmta ofmtbig ofmtfidl ofmts ofs1 onlynl opasnidx opasnslf \
+ paramasfunc1 paramasfunc2 \
paramdup paramres paramtyp paramuninitglobal parse1 parsefld parseme \
pcntplus posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \
prt1eval prtoeval \
@@ -2586,6 +2593,11 @@ badbuild:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+callparam:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
childin:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@@ -3056,6 +3068,16 @@ opasnslf:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+paramasfunc1:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
+paramasfunc2:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
paramdup:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 5c4c40f9..41c85c01 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -130,6 +130,11 @@ badbuild:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+callparam:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
childin:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@@ -600,6 +605,16 @@ opasnslf:
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+paramasfunc1:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
+paramasfunc2:
+ @echo $@
+ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
paramdup:
@echo $@
@AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
diff --git a/test/callparam.awk b/test/callparam.awk
new file mode 100644
index 00000000..b925db01
--- /dev/null
+++ b/test/callparam.awk
@@ -0,0 +1,6 @@
+BEGIN { f() }
+
+function f( a, b)
+{
+ a = b()
+}
diff --git a/test/callparam.ok b/test/callparam.ok
new file mode 100644
index 00000000..00a027e8
--- /dev/null
+++ b/test/callparam.ok
@@ -0,0 +1,2 @@
+gawk: callparam.awk:5: error: attempt to use non-function `b' in function call
+EXIT CODE: 1
diff --git a/test/exit.sh b/test/exit.sh
index 9510dcdc..3922f83c 100755
--- a/test/exit.sh
+++ b/test/exit.sh
@@ -30,7 +30,7 @@ x='function f(){ exit}; BEGINFILE {f()}; NR>1{ f()}; END{print NR}'
$AWK 'BEGIN { print "a\nb" }' | $AWK "$x"
echo "-- 5"
-y='function strip(f) { sub(/.*\//, "", f); return f };'
+y='function strip(val) { sub(/.*\//, "", val); return val };'
x='BEGINFILE{if(++i==1) exit;}; END{print i, strip(FILENAME)}'
$AWK "$y$x" /dev/null $0
diff --git a/test/indirectcall.awk b/test/indirectcall.awk
index 5cfdd235..74290973 100644
--- a/test/indirectcall.awk
+++ b/test/indirectcall.awk
@@ -5,13 +5,13 @@
# average --- return the average of the values in fields $first - $last
-function average(first, last, sum, i)
+function average(first, last, the_sum, i)
{
- sum = 0;
+ the_sum = 0;
for (i = first; i <= last; i++)
- sum += $i
+ the_sum += $i
- return sum / (last - first + 1)
+ return the_sum / (last - first + 1)
}
# sum --- return the average of the values in fields $first - $last
diff --git a/test/paramasfunc1.awk b/test/paramasfunc1.awk
new file mode 100644
index 00000000..b0d06849
--- /dev/null
+++ b/test/paramasfunc1.awk
@@ -0,0 +1,9 @@
+BEGIN{ X() }
+
+function X( abc)
+{
+ abc = "stamp out "
+ print abc abc()
+}
+
+function abc() { return "dark corners" }
diff --git a/test/paramasfunc1.ok b/test/paramasfunc1.ok
new file mode 100644
index 00000000..9ee95116
--- /dev/null
+++ b/test/paramasfunc1.ok
@@ -0,0 +1,3 @@
+gawk: paramasfunc1.awk:6: error: attempt to use non-function `abc' in function call
+gawk: error: function `X': can't use function `abc' as a parameter name
+EXIT CODE: 1
diff --git a/test/paramasfunc2.awk b/test/paramasfunc2.awk
new file mode 100644
index 00000000..849b3d1b
--- /dev/null
+++ b/test/paramasfunc2.awk
@@ -0,0 +1,10 @@
+BEGIN{ X() }
+
+function abc() { return "dark corners" }
+
+function X( abc)
+{
+ abc = "stamp out "
+ print abc abc()
+}
+
diff --git a/test/paramasfunc2.ok b/test/paramasfunc2.ok
new file mode 100644
index 00000000..2cdf4f66
--- /dev/null
+++ b/test/paramasfunc2.ok
@@ -0,0 +1,3 @@
+gawk: paramasfunc2.awk:8: error: attempt to use non-function `abc' in function call
+gawk: error: function `X': can't use function `abc' as a parameter name
+EXIT CODE: 1