From 59514868fde1190f719e78d4c4b91bd14a321541 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Fri, 20 Mar 2015 10:31:49 +0200 Subject: Start on testing/fixing indirect calls of builtins. --- ChangeLog | 11 +++ awk.h | 1 + awkgram.c | 18 +++- awkgram.y | 18 +++- builtin.c | 23 +++++ indirectbuitin.awk | 247 +++++++++++++++++++++++++++++++++++++++++++++++++++++ interpret.h | 6 +- 7 files changed, 319 insertions(+), 5 deletions(-) create mode 100644 indirectbuitin.awk diff --git a/ChangeLog b/ChangeLog index b8b3ee9a..723ee3a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2015-03-20 Arnold D. Robbins + + Start on fixing indirect calls of builtins. + + * awk.h (call_sub_func): Add declaration. + * awkgram.y (lookup_builtin): Handle length, sub functions. + (install_builtin): Handle length function. + * builtin.c (call_sub_func): New function. + * interpret.h (r_interpret): If calling do_sub, do it through + call_sub_func(). + 2015-03-18 Arnold D. Robbins * config.guess, config.sub: Updated, from libtool 2.4.6. diff --git a/awk.h b/awk.h index 08c6891c..f2ef3582 100644 --- a/awk.h +++ b/awk.h @@ -1360,6 +1360,7 @@ extern NODE *do_rand(int nargs); extern NODE *do_srand(int nargs); extern NODE *do_match(int nargs); extern NODE *do_sub(int nargs, unsigned int flags); +extern NODE *call_sub_func(const char *name, int nargs); extern NODE *format_tree(const char *, size_t, NODE **, long); extern NODE *do_lshift(int nargs); extern NODE *do_rshift(int nargs); diff --git a/awkgram.c b/awkgram.c index 5376d010..ec9b16ac 100644 --- a/awkgram.c +++ b/awkgram.c @@ -7969,13 +7969,26 @@ lookup_builtin(const char *name) { int mid = check_special(name); - if (mid == -1 || tokentab[mid].class != LEX_BUILTIN) + if (mid == -1) return NULL; + + switch (tokentab[mid].class) { + case LEX_BUILTIN: + case LEX_LENGTH: + break; + default: + return NULL; + } + #ifdef HAVE_MPFR if (do_mpfr) return tokentab[mid].ptr2; #endif + /* And another special case... */ + if (tokentab[mid].value == Op_sub_builtin) + return (builtin_func_t) do_sub; + return tokentab[mid].ptr; } @@ -7988,7 +8001,8 @@ install_builtins(void) j = sizeof(tokentab) / sizeof(tokentab[0]); for (i = 0; i < j; i++) { - if ( tokentab[i].class == LEX_BUILTIN + if ( (tokentab[i].class == LEX_BUILTIN + || tokentab[i].class == LEX_LENGTH) && (tokentab[i].flags & DEBUG_USE) == 0) { (void) install_symbol(tokentab[i].operator, Node_builtin_func); } diff --git a/awkgram.y b/awkgram.y index 2307c362..2be4d37c 100644 --- a/awkgram.y +++ b/awkgram.y @@ -5630,13 +5630,26 @@ lookup_builtin(const char *name) { int mid = check_special(name); - if (mid == -1 || tokentab[mid].class != LEX_BUILTIN) + if (mid == -1) return NULL; + + switch (tokentab[mid].class) { + case LEX_BUILTIN: + case LEX_LENGTH: + break; + default: + return NULL; + } + #ifdef HAVE_MPFR if (do_mpfr) return tokentab[mid].ptr2; #endif + /* And another special case... */ + if (tokentab[mid].value == Op_sub_builtin) + return (builtin_func_t) do_sub; + return tokentab[mid].ptr; } @@ -5649,7 +5662,8 @@ install_builtins(void) j = sizeof(tokentab) / sizeof(tokentab[0]); for (i = 0; i < j; i++) { - if ( tokentab[i].class == LEX_BUILTIN + if ( (tokentab[i].class == LEX_BUILTIN + || tokentab[i].class == LEX_LENGTH) && (tokentab[i].flags & DEBUG_USE) == 0) { (void) install_symbol(tokentab[i].operator, Node_builtin_func); } diff --git a/builtin.c b/builtin.c index 1383572a..4dd08eb1 100644 --- a/builtin.c +++ b/builtin.c @@ -2994,6 +2994,29 @@ done: return make_number((AWKNUM) matches); } +/* call_sub_func --- call do_sub indirectly */ + +NODE * +call_sub_func(const char *name, int nargs) +{ + unsigned int flags = 0; + NODE *tmp; + + if (name[0] == 'g') { + if (name[1] == 'e') + flags = GENSUB; + else + flags = GSUB; + } + + tmp = PEEK(1); + if (tmp->type == Node_val) { + flags |= LITERAL; + } + + return do_sub(nargs, flags); +} + /* make_integer - Convert an integer to a number node. */ diff --git a/indirectbuitin.awk b/indirectbuitin.awk new file mode 100644 index 00000000..26cb5cc4 --- /dev/null +++ b/indirectbuitin.awk @@ -0,0 +1,247 @@ +function print_result(category, fname, builtin_result, indirect_result) +{ + if (builtin_result == indirect_result) + printf("%s: %s: pass\n", category, fname) + else + printf("%s: %s: fail: builtin: %s \tindirect: %s\n", category, fname, + builtin_result, indirect_result) +} + +BEGIN { + + fun = "sub" + x = "ff11bb" + b1 = sub("f", "q", x) + i1 = @fun("f", "q", x) + print_result("string", fun, b1, i1) +} + + +BEGIN { +# math functions + + fun = "and" + b1 = and(0x11, 0x01) + i1 = @fun(0x11, 0x01) + print_result("math", fun, b1, i1) + + fun = "atan2" + b1 = atan2(-1, 0) + i1 = @fun(-1, 0) + print_result("math", fun, b1, i1) + + fun = "compl" + b1 = compl(0x1111) + i1 = @fun(0x1111) + print_result("math", fun, b1, i1) + + fun = "cos" + b1 = cos(3.1415927 / 4) + i1 = @fun(3.1415927 / 4) + print_result("math", fun, b1, i1) + + fun = "exp" + b1 = exp(2) + i1 = @fun(2) + print_result("math", fun, b1, i1) + + fun = "int" + b1 = int(3.1415927) + i1 = @fun(3.1415927) + print_result("math", fun, b1, i1) + + fun = "log" + b1 = log(10) + i1 = @fun(10) + print_result("math", fun, b1, i1) + + fun = "lshift" + b1 = lshift(1, 2) + i1 = @fun(1, 2) + print_result("math", fun, b1, i1) + + fun = "or" + b1 = or(0x10, 0x01) + i1 = @fun(0x10, 0x01) + print_result("math", fun, b1, i1) + + fun = "rand" + srand(1) + b1 = rand(); + srand(1) + i1 = @fun() + print_result("math", fun, b1, i1) + + fun = "rshift" + b1 = rshift(0x10, 1) + i1 = @fun(0x10, 1) + print_result("math", fun, b1, i1) + + fun = "sin" + b1 = sin(3.1415927 / 4) + i1 = @fun(3.1415927 / 4) + print_result("math", fun, b1, i1) + + fun = "sqrt" + b1 = sqrt(2) + i1 = @fun(2) + print_result("math", fun, b1, i1) + + srand() + fun = "srand" + b1 = srand() + i1 = @fun() + print_result("math", fun, b1, i1) + + fun = "xor" + b1 = xor(0x11, 0x01) + i1 = @fun(0x11, 0x01) + print_result("math", fun, b1, i1) + +# string functions + +# fun = "gensub" +# b1 = gensub("f", "q","g", "ff11bb") +# i1 = @fun("f", "q", "g", "ff11bb") +# print_result("string", fun, b1, i1) + +# fun = "gsub" +# x = "ff11bb" +# b1 = gsub("f", "q", x) +# i1 = @fun("f", "q", x) +# print_result("string", fun, b1, i1) + + fun = "index" + b1 = index("hi, how are you", "how") + i1 = @fun("hi, how are you", "how") + print_result("string", fun, b1, i1) + + fun = "dcgettext" + b1 = dcgettext("hello, world") + i1 = @fun("hello, world") + print_result("string", fun, b1, i1) + + fun = "dcngettext" + b1 = dcngettext("hello, world", "howdy", 2) + i1 = @fun("hello, world", "howdy", 2) + print_result("string", fun, b1, i1) + + fun = "length" + b1 = length("hi, how are you") + i1 = @fun("hi, how are you") + print_result("string", fun, b1, i1) + + fun = "sprintf" + b1 = sprintf("%s world", "hello") + i1 = @fun("%s world", "hello") + print_result("string", fun, b1, i1) + + fun = "strtonum" + b1 = strtonum("0xdeadbeef") + i1 = @fun("0xdeadbeef") + print_result("string", fun, b1, i1) + + fun = "sub" + x = "ff11bb" + b1 = sub("f", "q", x) + i1 = @fun("f", "q", x) + print_result("string", fun, b1, i1) + + fun = "substr" + b1 = substr("0xdeadbeef", 7, 4) + i1 = @fun("0xdeadbeef", 7, 4) + print_result("string", fun, b1, i1) + + fun = "tolower" + b1 = tolower("0xDeAdBeEf") + i1 = @fun("0xDeAdBeEf") + print_result("string", fun, b1, i1) + + fun = "toupper" + b1 = toupper("0xDeAdBeEf") + i1 = @fun("0xDeAdBeEf") + print_result("string", fun, b1, i1) + +# time functions + + fun = "mktime" + b1 = mktime("1990 02 11 12 00 00") + i1 = @fun("1990 02 11 12 00 00") + print_result("time", fun, b1, i1) + + then = b1 + fun = "strftime" + b1 = strftime(PROCINFO["strftime"], then) + i1 = @fun(PROCINFO["strftime"], then) + print_result("time", fun, b1, i1) + + fun = "systime" + b1 = systime() + i1 = @fun() + print_result("time", fun, b1, i1) + +# regexp functions + +# fun = "match" +# print_result("regexp", fun, b1, i1) + +# fun = "patsplit" +# print_result("regexp", fun, b1, i1) + +# fun = "split" +# print_result("regexp", fun, b1, i1) + +# array functions + + split("z y x w v u t", data) + fun = "asort" + asort(data, newdata) + @fun(data, newdata2) + print_result("array", fun, b1, i1) + for (i in newdata) { + if (! (i in newdata2) || newdata[i] != newdata2[i]) { + print fun ": failed, index", i + exit + } + } + + for (i in data) + data2[data[i]] = i + + fun = "asorti" + asort(data2, newdata) + @fun(data2, newdata2) + print_result("array", fun, b1, i1) + for (i in newdata) { + if (! (i in newdata2) || newdata[i] != newdata2[i]) { + print fun ": failed, index", i + exit + } + } + + arr[1] = arr[2] = 42 + fun = "isarray" + b1 = isarray(arr) + i1 = @fun(arr) + print_result("array", fun, b1, i1) + +# i/o functions + + print("hi") > "x1.out" + print("hi") > "x2.out" + + fun = "fflush" + b1 = fflush("x1.out") + i1 = @fun("x2.out") + print_result("i/o", fun, b1, i1) + + fun = "close" + b1 = close("x1.out") + i1 = @fun("x2.out") + print_result("i/o", fun, b1, i1) + + fun = "system" + b1 = system("rm x1.out") + i1 = @fun("rm x2.out") + print_result("i/o", fun, b1, i1) +} diff --git a/interpret.h b/interpret.h index b16dc126..9160d479 100644 --- a/interpret.h +++ b/interpret.h @@ -1066,7 +1066,11 @@ match_re: assert(the_func != NULL); /* call it */ - r = the_func(arg_count); + if (the_func == do_sub) + r = call_sub_func(t1->stptr, arg_count); + else + r = the_func(arg_count); + PUSH(r); break; } else if (f->type != Node_func) { -- cgit v1.2.1 From 75459887958f5246bc5126261ec92c8f4d366a47 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 24 Mar 2015 22:12:17 +0200 Subject: Fix a test. --- test/ChangeLog | 4 ++++ test/id.ok | 1 + 2 files changed, 5 insertions(+) diff --git a/test/ChangeLog b/test/ChangeLog index c33ac108..ab7a2163 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2015-03-24 Arnold D. Robbins + + * id.ok: Update after fixes in code. + 2015-03-17 Andrew J. Schorr * inplace1.ok, inplace2.ok, inplace3.ok: Update error message line diff --git a/test/id.ok b/test/id.ok index a3271cff..011d6cf2 100644 --- a/test/id.ok +++ b/test/id.ok @@ -14,6 +14,7 @@ sprintf -> builtin ROUNDMODE -> scalar strftime -> builtin systime -> builtin +length -> builtin and -> builtin srand -> builtin FNR -> scalar -- cgit v1.2.1 From 080694ae82635e76992158591b39a06af7363da0 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 24 Mar 2015 22:15:31 +0200 Subject: Further progress on indirect calls of builtins. --- ChangeLog | 9 + awk.h | 1 + awkgram.c | 721 ++++++++++++++++++++++++++--------------------------- awkgram.y | 3 +- builtin.c | 15 +- indirectbuitin.awk | 9 +- interpret.h | 2 +- node.c | 8 + 8 files changed, 395 insertions(+), 373 deletions(-) diff --git a/ChangeLog b/ChangeLog index 723ee3a6..8610df82 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2015-03-24 Arnold D. Robbins + + * awkgram.y (make_regnode): Make extern. + * awk.h (make_regnode): Declare. + * builtin.c (call_sub_func): Start on reworking the stack to + be what do_sub() expects. Still needs work. + * interpret.h (r_interpret): Add a cast in comparison with do_sub(). + * node.c (r_unref): Handle Node_regex nodes. + 2015-03-20 Arnold D. Robbins Start on fixing indirect calls of builtins. diff --git a/awk.h b/awk.h index f2ef3582..f23977fb 100644 --- a/awk.h +++ b/awk.h @@ -1331,6 +1331,7 @@ extern void install_builtins(void); extern bool is_alpha(int c); extern bool is_alnum(int c); extern bool is_identchar(int c); +extern NODE *make_regnode(int type, NODE *exp); /* builtin.c */ extern double double_to_int(double d); extern NODE *do_exp(int nargs); diff --git a/awkgram.c b/awkgram.c index ec9b16ac..fcde2564 100644 --- a/awkgram.c +++ b/awkgram.c @@ -113,7 +113,6 @@ static INSTRUCTION *mk_binary(INSTRUCTION *s1, INSTRUCTION *s2, INSTRUCTION *op) static INSTRUCTION *mk_boolean(INSTRUCTION *left, INSTRUCTION *right, INSTRUCTION *op); static INSTRUCTION *mk_assignment(INSTRUCTION *lhs, INSTRUCTION *rhs, INSTRUCTION *op); static INSTRUCTION *mk_getline(INSTRUCTION *op, INSTRUCTION *opt_var, INSTRUCTION *redir, int redirtype); -static NODE *make_regnode(int type, NODE *exp); static int count_expressions(INSTRUCTION **list, bool isarg); static INSTRUCTION *optimize_assignment(INSTRUCTION *exp); static void add_lint(INSTRUCTION *list, LINTTYPE linttype); @@ -192,7 +191,7 @@ extern double fmod(double x, double y); #define YYSTYPE INSTRUCTION * -#line 196 "awkgram.c" /* yacc.c:339 */ +#line 195 "awkgram.c" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus @@ -346,7 +345,7 @@ int yyparse (void); /* Copy the second part of user declarations. */ -#line 350 "awkgram.c" /* yacc.c:358 */ +#line 349 "awkgram.c" /* yacc.c:358 */ #ifdef short # undef short @@ -648,25 +647,25 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 195, 195, 197, 202, 203, 207, 219, 223, 234, - 240, 246, 255, 263, 265, 270, 278, 280, 286, 287, - 289, 315, 326, 337, 343, 352, 362, 364, 366, 372, - 380, 381, 385, 404, 403, 437, 439, 444, 445, 458, - 463, 464, 468, 470, 472, 479, 569, 611, 653, 766, - 773, 780, 790, 799, 808, 817, 828, 844, 843, 867, - 879, 879, 977, 977, 1010, 1040, 1046, 1047, 1053, 1054, - 1061, 1066, 1078, 1092, 1094, 1102, 1107, 1109, 1117, 1119, - 1128, 1129, 1137, 1142, 1142, 1153, 1157, 1165, 1166, 1169, - 1171, 1176, 1177, 1186, 1187, 1192, 1197, 1203, 1205, 1207, - 1214, 1215, 1221, 1222, 1227, 1229, 1234, 1236, 1244, 1249, - 1258, 1265, 1267, 1269, 1285, 1295, 1302, 1304, 1309, 1311, - 1313, 1321, 1323, 1328, 1330, 1335, 1337, 1339, 1389, 1391, - 1393, 1395, 1397, 1399, 1401, 1403, 1417, 1422, 1427, 1452, - 1458, 1460, 1462, 1464, 1466, 1468, 1473, 1477, 1509, 1511, - 1517, 1523, 1536, 1537, 1538, 1543, 1548, 1552, 1556, 1571, - 1584, 1589, 1626, 1655, 1656, 1662, 1663, 1668, 1670, 1677, - 1694, 1711, 1713, 1720, 1725, 1733, 1743, 1755, 1764, 1768, - 1772, 1776, 1780, 1784, 1787, 1789, 1793, 1797, 1801 + 0, 194, 194, 196, 201, 202, 206, 218, 222, 233, + 239, 245, 254, 262, 264, 269, 277, 279, 285, 286, + 288, 314, 325, 336, 342, 351, 361, 363, 365, 371, + 379, 380, 384, 403, 402, 436, 438, 443, 444, 457, + 462, 463, 467, 469, 471, 478, 568, 610, 652, 765, + 772, 779, 789, 798, 807, 816, 827, 843, 842, 866, + 878, 878, 976, 976, 1009, 1039, 1045, 1046, 1052, 1053, + 1060, 1065, 1077, 1091, 1093, 1101, 1106, 1108, 1116, 1118, + 1127, 1128, 1136, 1141, 1141, 1152, 1156, 1164, 1165, 1168, + 1170, 1175, 1176, 1185, 1186, 1191, 1196, 1202, 1204, 1206, + 1213, 1214, 1220, 1221, 1226, 1228, 1233, 1235, 1243, 1248, + 1257, 1264, 1266, 1268, 1284, 1294, 1301, 1303, 1308, 1310, + 1312, 1320, 1322, 1327, 1329, 1334, 1336, 1338, 1388, 1390, + 1392, 1394, 1396, 1398, 1400, 1402, 1416, 1421, 1426, 1451, + 1457, 1459, 1461, 1463, 1465, 1467, 1472, 1476, 1508, 1510, + 1516, 1522, 1535, 1536, 1537, 1542, 1547, 1551, 1555, 1570, + 1583, 1588, 1625, 1654, 1655, 1661, 1662, 1667, 1669, 1676, + 1693, 1710, 1712, 1719, 1724, 1732, 1742, 1754, 1763, 1767, + 1771, 1775, 1779, 1783, 1786, 1788, 1792, 1796, 1800 }; #endif @@ -1839,24 +1838,24 @@ yyreduce: switch (yyn) { case 3: -#line 198 "awkgram.y" /* yacc.c:1646 */ +#line 197 "awkgram.y" /* yacc.c:1646 */ { rule = 0; yyerrok; } -#line 1848 "awkgram.c" /* yacc.c:1646 */ +#line 1847 "awkgram.c" /* yacc.c:1646 */ break; case 5: -#line 204 "awkgram.y" /* yacc.c:1646 */ +#line 203 "awkgram.y" /* yacc.c:1646 */ { next_sourcefile(); } -#line 1856 "awkgram.c" /* yacc.c:1646 */ +#line 1855 "awkgram.c" /* yacc.c:1646 */ break; case 6: -#line 208 "awkgram.y" /* yacc.c:1646 */ +#line 207 "awkgram.y" /* yacc.c:1646 */ { rule = 0; /* @@ -1865,19 +1864,19 @@ yyreduce: */ /* yyerrok; */ } -#line 1869 "awkgram.c" /* yacc.c:1646 */ +#line 1868 "awkgram.c" /* yacc.c:1646 */ break; case 7: -#line 220 "awkgram.y" /* yacc.c:1646 */ +#line 219 "awkgram.y" /* yacc.c:1646 */ { (void) append_rule((yyvsp[-1]), (yyvsp[0])); } -#line 1877 "awkgram.c" /* yacc.c:1646 */ +#line 1876 "awkgram.c" /* yacc.c:1646 */ break; case 8: -#line 224 "awkgram.y" /* yacc.c:1646 */ +#line 223 "awkgram.y" /* yacc.c:1646 */ { if (rule != Rule) { msg(_("%s blocks must have an action part"), ruletab[rule]); @@ -1888,41 +1887,41 @@ yyreduce: } else /* pattern rule with non-empty pattern */ (void) append_rule((yyvsp[-1]), NULL); } -#line 1892 "awkgram.c" /* yacc.c:1646 */ +#line 1891 "awkgram.c" /* yacc.c:1646 */ break; case 9: -#line 235 "awkgram.y" /* yacc.c:1646 */ +#line 234 "awkgram.y" /* yacc.c:1646 */ { in_function = NULL; (void) mk_function((yyvsp[-1]), (yyvsp[0])); yyerrok; } -#line 1902 "awkgram.c" /* yacc.c:1646 */ +#line 1901 "awkgram.c" /* yacc.c:1646 */ break; case 10: -#line 241 "awkgram.y" /* yacc.c:1646 */ +#line 240 "awkgram.y" /* yacc.c:1646 */ { want_source = false; at_seen = false; yyerrok; } -#line 1912 "awkgram.c" /* yacc.c:1646 */ +#line 1911 "awkgram.c" /* yacc.c:1646 */ break; case 11: -#line 247 "awkgram.y" /* yacc.c:1646 */ +#line 246 "awkgram.y" /* yacc.c:1646 */ { want_source = false; at_seen = false; yyerrok; } -#line 1922 "awkgram.c" /* yacc.c:1646 */ +#line 1921 "awkgram.c" /* yacc.c:1646 */ break; case 12: -#line 256 "awkgram.y" /* yacc.c:1646 */ +#line 255 "awkgram.y" /* yacc.c:1646 */ { if (include_source((yyvsp[0])) < 0) YYABORT; @@ -1930,23 +1929,23 @@ yyreduce: bcfree((yyvsp[0])); (yyval) = NULL; } -#line 1934 "awkgram.c" /* yacc.c:1646 */ +#line 1933 "awkgram.c" /* yacc.c:1646 */ break; case 13: -#line 264 "awkgram.y" /* yacc.c:1646 */ +#line 263 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1940 "awkgram.c" /* yacc.c:1646 */ +#line 1939 "awkgram.c" /* yacc.c:1646 */ break; case 14: -#line 266 "awkgram.y" /* yacc.c:1646 */ +#line 265 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1946 "awkgram.c" /* yacc.c:1646 */ +#line 1945 "awkgram.c" /* yacc.c:1646 */ break; case 15: -#line 271 "awkgram.y" /* yacc.c:1646 */ +#line 270 "awkgram.y" /* yacc.c:1646 */ { if (load_library((yyvsp[0])) < 0) YYABORT; @@ -1954,35 +1953,35 @@ yyreduce: bcfree((yyvsp[0])); (yyval) = NULL; } -#line 1958 "awkgram.c" /* yacc.c:1646 */ +#line 1957 "awkgram.c" /* yacc.c:1646 */ break; case 16: -#line 279 "awkgram.y" /* yacc.c:1646 */ +#line 278 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1964 "awkgram.c" /* yacc.c:1646 */ +#line 1963 "awkgram.c" /* yacc.c:1646 */ break; case 17: -#line 281 "awkgram.y" /* yacc.c:1646 */ +#line 280 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1970 "awkgram.c" /* yacc.c:1646 */ +#line 1969 "awkgram.c" /* yacc.c:1646 */ break; case 18: -#line 286 "awkgram.y" /* yacc.c:1646 */ +#line 285 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; rule = Rule; } -#line 1976 "awkgram.c" /* yacc.c:1646 */ +#line 1975 "awkgram.c" /* yacc.c:1646 */ break; case 19: -#line 288 "awkgram.y" /* yacc.c:1646 */ +#line 287 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); rule = Rule; } -#line 1982 "awkgram.c" /* yacc.c:1646 */ +#line 1981 "awkgram.c" /* yacc.c:1646 */ break; case 20: -#line 290 "awkgram.y" /* yacc.c:1646 */ +#line 289 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *tp; @@ -2008,11 +2007,11 @@ yyreduce: (yyval) = list_append(list_merge((yyvsp[-3]), (yyvsp[0])), tp); rule = Rule; } -#line 2012 "awkgram.c" /* yacc.c:1646 */ +#line 2011 "awkgram.c" /* yacc.c:1646 */ break; case 21: -#line 316 "awkgram.y" /* yacc.c:1646 */ +#line 315 "awkgram.y" /* yacc.c:1646 */ { static int begin_seen = 0; if (do_lint_old && ++begin_seen == 2) @@ -2023,11 +2022,11 @@ yyreduce: (yyvsp[0])->source_file = source; (yyval) = (yyvsp[0]); } -#line 2027 "awkgram.c" /* yacc.c:1646 */ +#line 2026 "awkgram.c" /* yacc.c:1646 */ break; case 22: -#line 327 "awkgram.y" /* yacc.c:1646 */ +#line 326 "awkgram.y" /* yacc.c:1646 */ { static int end_seen = 0; if (do_lint_old && ++end_seen == 2) @@ -2038,73 +2037,73 @@ yyreduce: (yyvsp[0])->source_file = source; (yyval) = (yyvsp[0]); } -#line 2042 "awkgram.c" /* yacc.c:1646 */ +#line 2041 "awkgram.c" /* yacc.c:1646 */ break; case 23: -#line 338 "awkgram.y" /* yacc.c:1646 */ +#line 337 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->in_rule = rule = BEGINFILE; (yyvsp[0])->source_file = source; (yyval) = (yyvsp[0]); } -#line 2052 "awkgram.c" /* yacc.c:1646 */ +#line 2051 "awkgram.c" /* yacc.c:1646 */ break; case 24: -#line 344 "awkgram.y" /* yacc.c:1646 */ +#line 343 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->in_rule = rule = ENDFILE; (yyvsp[0])->source_file = source; (yyval) = (yyvsp[0]); } -#line 2062 "awkgram.c" /* yacc.c:1646 */ +#line 2061 "awkgram.c" /* yacc.c:1646 */ break; case 25: -#line 353 "awkgram.y" /* yacc.c:1646 */ +#line 352 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-3]) == NULL) (yyval) = list_create(instruction(Op_no_op)); else (yyval) = (yyvsp[-3]); } -#line 2073 "awkgram.c" /* yacc.c:1646 */ +#line 2072 "awkgram.c" /* yacc.c:1646 */ break; case 26: -#line 363 "awkgram.y" /* yacc.c:1646 */ +#line 362 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2079 "awkgram.c" /* yacc.c:1646 */ +#line 2078 "awkgram.c" /* yacc.c:1646 */ break; case 27: -#line 365 "awkgram.y" /* yacc.c:1646 */ +#line 364 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2085 "awkgram.c" /* yacc.c:1646 */ +#line 2084 "awkgram.c" /* yacc.c:1646 */ break; case 28: -#line 367 "awkgram.y" /* yacc.c:1646 */ +#line 366 "awkgram.y" /* yacc.c:1646 */ { yyerror(_("`%s' is a built-in function, it cannot be redefined"), tokstart); YYABORT; } -#line 2095 "awkgram.c" /* yacc.c:1646 */ +#line 2094 "awkgram.c" /* yacc.c:1646 */ break; case 29: -#line 373 "awkgram.y" /* yacc.c:1646 */ +#line 372 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); at_seen = false; } -#line 2104 "awkgram.c" /* yacc.c:1646 */ +#line 2103 "awkgram.c" /* yacc.c:1646 */ break; case 32: -#line 386 "awkgram.y" /* yacc.c:1646 */ +#line 385 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[-5])->source_file = source; if (install_function((yyvsp[-4])->lextok, (yyvsp[-5]), (yyvsp[-2])) < 0) @@ -2115,17 +2114,17 @@ yyreduce: /* $4 already free'd in install_function */ (yyval) = (yyvsp[-5]); } -#line 2119 "awkgram.c" /* yacc.c:1646 */ +#line 2118 "awkgram.c" /* yacc.c:1646 */ break; case 33: -#line 404 "awkgram.y" /* yacc.c:1646 */ +#line 403 "awkgram.y" /* yacc.c:1646 */ { want_regexp = true; } -#line 2125 "awkgram.c" /* yacc.c:1646 */ +#line 2124 "awkgram.c" /* yacc.c:1646 */ break; case 34: -#line 406 "awkgram.y" /* yacc.c:1646 */ +#line 405 "awkgram.y" /* yacc.c:1646 */ { NODE *n, *exp; char *re; @@ -2154,23 +2153,23 @@ yyreduce: (yyval)->opcode = Op_match_rec; (yyval)->memory = n; } -#line 2158 "awkgram.c" /* yacc.c:1646 */ +#line 2157 "awkgram.c" /* yacc.c:1646 */ break; case 35: -#line 438 "awkgram.y" /* yacc.c:1646 */ +#line 437 "awkgram.y" /* yacc.c:1646 */ { bcfree((yyvsp[0])); } -#line 2164 "awkgram.c" /* yacc.c:1646 */ +#line 2163 "awkgram.c" /* yacc.c:1646 */ break; case 37: -#line 444 "awkgram.y" /* yacc.c:1646 */ +#line 443 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2170 "awkgram.c" /* yacc.c:1646 */ +#line 2169 "awkgram.c" /* yacc.c:1646 */ break; case 38: -#line 446 "awkgram.y" /* yacc.c:1646 */ +#line 445 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[0]) == NULL) (yyval) = (yyvsp[-1]); @@ -2183,40 +2182,40 @@ yyreduce: } yyerrok; } -#line 2187 "awkgram.c" /* yacc.c:1646 */ +#line 2186 "awkgram.c" /* yacc.c:1646 */ break; case 39: -#line 459 "awkgram.y" /* yacc.c:1646 */ +#line 458 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2193 "awkgram.c" /* yacc.c:1646 */ +#line 2192 "awkgram.c" /* yacc.c:1646 */ break; case 42: -#line 469 "awkgram.y" /* yacc.c:1646 */ +#line 468 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2199 "awkgram.c" /* yacc.c:1646 */ +#line 2198 "awkgram.c" /* yacc.c:1646 */ break; case 43: -#line 471 "awkgram.y" /* yacc.c:1646 */ +#line 470 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 2205 "awkgram.c" /* yacc.c:1646 */ +#line 2204 "awkgram.c" /* yacc.c:1646 */ break; case 44: -#line 473 "awkgram.y" /* yacc.c:1646 */ +#line 472 "awkgram.y" /* yacc.c:1646 */ { if (do_pretty_print) (yyval) = list_prepend((yyvsp[0]), instruction(Op_exec_count)); else (yyval) = (yyvsp[0]); } -#line 2216 "awkgram.c" /* yacc.c:1646 */ +#line 2215 "awkgram.c" /* yacc.c:1646 */ break; case 45: -#line 480 "awkgram.y" /* yacc.c:1646 */ +#line 479 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *dflt, *curr = NULL, *cexp, *cstmt; INSTRUCTION *ip, *nextc, *tbreak; @@ -2306,11 +2305,11 @@ yyreduce: break_allowed--; fix_break_continue(ip, tbreak, NULL); } -#line 2310 "awkgram.c" /* yacc.c:1646 */ +#line 2309 "awkgram.c" /* yacc.c:1646 */ break; case 46: -#line 570 "awkgram.y" /* yacc.c:1646 */ +#line 569 "awkgram.y" /* yacc.c:1646 */ { /* * ----------------- @@ -2352,11 +2351,11 @@ yyreduce: continue_allowed--; fix_break_continue(ip, tbreak, tcont); } -#line 2356 "awkgram.c" /* yacc.c:1646 */ +#line 2355 "awkgram.c" /* yacc.c:1646 */ break; case 47: -#line 612 "awkgram.y" /* yacc.c:1646 */ +#line 611 "awkgram.y" /* yacc.c:1646 */ { /* * ----------------- @@ -2398,11 +2397,11 @@ yyreduce: } /* else $1 and $4 are NULLs */ } -#line 2402 "awkgram.c" /* yacc.c:1646 */ +#line 2401 "awkgram.c" /* yacc.c:1646 */ break; case 48: -#line 654 "awkgram.y" /* yacc.c:1646 */ +#line 653 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *ip; char *var_name = (yyvsp[-5])->lextok; @@ -2515,44 +2514,44 @@ regular_loop: break_allowed--; continue_allowed--; } -#line 2519 "awkgram.c" /* yacc.c:1646 */ +#line 2518 "awkgram.c" /* yacc.c:1646 */ break; case 49: -#line 767 "awkgram.y" /* yacc.c:1646 */ +#line 766 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_for_loop((yyvsp[-11]), (yyvsp[-9]), (yyvsp[-6]), (yyvsp[-3]), (yyvsp[0])); break_allowed--; continue_allowed--; } -#line 2530 "awkgram.c" /* yacc.c:1646 */ +#line 2529 "awkgram.c" /* yacc.c:1646 */ break; case 50: -#line 774 "awkgram.y" /* yacc.c:1646 */ +#line 773 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_for_loop((yyvsp[-10]), (yyvsp[-8]), (INSTRUCTION *) NULL, (yyvsp[-3]), (yyvsp[0])); break_allowed--; continue_allowed--; } -#line 2541 "awkgram.c" /* yacc.c:1646 */ +#line 2540 "awkgram.c" /* yacc.c:1646 */ break; case 51: -#line 781 "awkgram.y" /* yacc.c:1646 */ +#line 780 "awkgram.y" /* yacc.c:1646 */ { if (do_pretty_print) (yyval) = list_prepend((yyvsp[0]), instruction(Op_exec_count)); else (yyval) = (yyvsp[0]); } -#line 2552 "awkgram.c" /* yacc.c:1646 */ +#line 2551 "awkgram.c" /* yacc.c:1646 */ break; case 52: -#line 791 "awkgram.y" /* yacc.c:1646 */ +#line 790 "awkgram.y" /* yacc.c:1646 */ { if (! break_allowed) error_ln((yyvsp[-1])->source_line, @@ -2561,11 +2560,11 @@ regular_loop: (yyval) = list_create((yyvsp[-1])); } -#line 2565 "awkgram.c" /* yacc.c:1646 */ +#line 2564 "awkgram.c" /* yacc.c:1646 */ break; case 53: -#line 800 "awkgram.y" /* yacc.c:1646 */ +#line 799 "awkgram.y" /* yacc.c:1646 */ { if (! continue_allowed) error_ln((yyvsp[-1])->source_line, @@ -2574,11 +2573,11 @@ regular_loop: (yyval) = list_create((yyvsp[-1])); } -#line 2578 "awkgram.c" /* yacc.c:1646 */ +#line 2577 "awkgram.c" /* yacc.c:1646 */ break; case 54: -#line 809 "awkgram.y" /* yacc.c:1646 */ +#line 808 "awkgram.y" /* yacc.c:1646 */ { /* if inside function (rule = 0), resolve context at run-time */ if (rule && rule != Rule) @@ -2587,11 +2586,11 @@ regular_loop: (yyvsp[-1])->target_jmp = ip_rec; (yyval) = list_create((yyvsp[-1])); } -#line 2591 "awkgram.c" /* yacc.c:1646 */ +#line 2590 "awkgram.c" /* yacc.c:1646 */ break; case 55: -#line 818 "awkgram.y" /* yacc.c:1646 */ +#line 817 "awkgram.y" /* yacc.c:1646 */ { /* if inside function (rule = 0), resolve context at run-time */ if (rule == BEGIN || rule == END || rule == ENDFILE) @@ -2602,11 +2601,11 @@ regular_loop: (yyvsp[-1])->target_endfile = ip_endfile; (yyval) = list_create((yyvsp[-1])); } -#line 2606 "awkgram.c" /* yacc.c:1646 */ +#line 2605 "awkgram.c" /* yacc.c:1646 */ break; case 56: -#line 829 "awkgram.y" /* yacc.c:1646 */ +#line 828 "awkgram.y" /* yacc.c:1646 */ { /* Initialize the two possible jump targets, the actual target * is resolved at run-time. @@ -2621,20 +2620,20 @@ regular_loop: } else (yyval) = list_append((yyvsp[-1]), (yyvsp[-2])); } -#line 2625 "awkgram.c" /* yacc.c:1646 */ +#line 2624 "awkgram.c" /* yacc.c:1646 */ break; case 57: -#line 844 "awkgram.y" /* yacc.c:1646 */ +#line 843 "awkgram.y" /* yacc.c:1646 */ { if (! in_function) yyerror(_("`return' used outside function context")); } -#line 2634 "awkgram.c" /* yacc.c:1646 */ +#line 2633 "awkgram.c" /* yacc.c:1646 */ break; case 58: -#line 847 "awkgram.y" /* yacc.c:1646 */ +#line 846 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-1]) == NULL) { (yyval) = list_create((yyvsp[-3])); @@ -2655,17 +2654,17 @@ regular_loop: (yyval) = list_append((yyvsp[-1]), (yyvsp[-3])); } } -#line 2659 "awkgram.c" /* yacc.c:1646 */ +#line 2658 "awkgram.c" /* yacc.c:1646 */ break; case 60: -#line 879 "awkgram.y" /* yacc.c:1646 */ +#line 878 "awkgram.y" /* yacc.c:1646 */ { in_print = true; in_parens = 0; } -#line 2665 "awkgram.c" /* yacc.c:1646 */ +#line 2664 "awkgram.c" /* yacc.c:1646 */ break; case 61: -#line 880 "awkgram.y" /* yacc.c:1646 */ +#line 879 "awkgram.y" /* yacc.c:1646 */ { /* * Optimization: plain `print' has no expression list, so $3 is null. @@ -2762,17 +2761,17 @@ regular_print: } } } -#line 2766 "awkgram.c" /* yacc.c:1646 */ +#line 2765 "awkgram.c" /* yacc.c:1646 */ break; case 62: -#line 977 "awkgram.y" /* yacc.c:1646 */ +#line 976 "awkgram.y" /* yacc.c:1646 */ { sub_counter = 0; } -#line 2772 "awkgram.c" /* yacc.c:1646 */ +#line 2771 "awkgram.c" /* yacc.c:1646 */ break; case 63: -#line 978 "awkgram.y" /* yacc.c:1646 */ +#line 977 "awkgram.y" /* yacc.c:1646 */ { char *arr = (yyvsp[-2])->lextok; @@ -2805,11 +2804,11 @@ regular_print: (yyval) = list_append(list_append((yyvsp[0]), (yyvsp[-2])), (yyvsp[-3])); } } -#line 2809 "awkgram.c" /* yacc.c:1646 */ +#line 2808 "awkgram.c" /* yacc.c:1646 */ break; case 64: -#line 1015 "awkgram.y" /* yacc.c:1646 */ +#line 1014 "awkgram.y" /* yacc.c:1646 */ { static bool warned = false; char *arr = (yyvsp[-1])->lextok; @@ -2835,52 +2834,52 @@ regular_print: fatal(_("`delete' is not allowed with FUNCTAB")); } } -#line 2839 "awkgram.c" /* yacc.c:1646 */ +#line 2838 "awkgram.c" /* yacc.c:1646 */ break; case 65: -#line 1041 "awkgram.y" /* yacc.c:1646 */ +#line 1040 "awkgram.y" /* yacc.c:1646 */ { (yyval) = optimize_assignment((yyvsp[0])); } -#line 2845 "awkgram.c" /* yacc.c:1646 */ +#line 2844 "awkgram.c" /* yacc.c:1646 */ break; case 66: -#line 1046 "awkgram.y" /* yacc.c:1646 */ +#line 1045 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2851 "awkgram.c" /* yacc.c:1646 */ +#line 2850 "awkgram.c" /* yacc.c:1646 */ break; case 67: -#line 1048 "awkgram.y" /* yacc.c:1646 */ +#line 1047 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2857 "awkgram.c" /* yacc.c:1646 */ +#line 2856 "awkgram.c" /* yacc.c:1646 */ break; case 68: -#line 1053 "awkgram.y" /* yacc.c:1646 */ +#line 1052 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2863 "awkgram.c" /* yacc.c:1646 */ +#line 2862 "awkgram.c" /* yacc.c:1646 */ break; case 69: -#line 1055 "awkgram.y" /* yacc.c:1646 */ +#line 1054 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-1]) == NULL) (yyval) = list_create((yyvsp[0])); else (yyval) = list_prepend((yyvsp[-1]), (yyvsp[0])); } -#line 2874 "awkgram.c" /* yacc.c:1646 */ +#line 2873 "awkgram.c" /* yacc.c:1646 */ break; case 70: -#line 1062 "awkgram.y" /* yacc.c:1646 */ +#line 1061 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2880 "awkgram.c" /* yacc.c:1646 */ +#line 2879 "awkgram.c" /* yacc.c:1646 */ break; case 71: -#line 1067 "awkgram.y" /* yacc.c:1646 */ +#line 1066 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *casestmt = (yyvsp[0]); if ((yyvsp[0]) == NULL) @@ -2892,11 +2891,11 @@ regular_print: bcfree((yyvsp[-2])); (yyval) = (yyvsp[-4]); } -#line 2896 "awkgram.c" /* yacc.c:1646 */ +#line 2895 "awkgram.c" /* yacc.c:1646 */ break; case 72: -#line 1079 "awkgram.y" /* yacc.c:1646 */ +#line 1078 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *casestmt = (yyvsp[0]); if ((yyvsp[0]) == NULL) @@ -2907,17 +2906,17 @@ regular_print: (yyvsp[-3])->case_stmt = casestmt; (yyval) = (yyvsp[-3]); } -#line 2911 "awkgram.c" /* yacc.c:1646 */ +#line 2910 "awkgram.c" /* yacc.c:1646 */ break; case 73: -#line 1093 "awkgram.y" /* yacc.c:1646 */ +#line 1092 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2917 "awkgram.c" /* yacc.c:1646 */ +#line 2916 "awkgram.c" /* yacc.c:1646 */ break; case 74: -#line 1095 "awkgram.y" /* yacc.c:1646 */ +#line 1094 "awkgram.y" /* yacc.c:1646 */ { NODE *n = (yyvsp[0])->memory; (void) force_number(n); @@ -2925,71 +2924,71 @@ regular_print: bcfree((yyvsp[-1])); (yyval) = (yyvsp[0]); } -#line 2929 "awkgram.c" /* yacc.c:1646 */ +#line 2928 "awkgram.c" /* yacc.c:1646 */ break; case 75: -#line 1103 "awkgram.y" /* yacc.c:1646 */ +#line 1102 "awkgram.y" /* yacc.c:1646 */ { bcfree((yyvsp[-1])); (yyval) = (yyvsp[0]); } -#line 2938 "awkgram.c" /* yacc.c:1646 */ +#line 2937 "awkgram.c" /* yacc.c:1646 */ break; case 76: -#line 1108 "awkgram.y" /* yacc.c:1646 */ +#line 1107 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2944 "awkgram.c" /* yacc.c:1646 */ +#line 2943 "awkgram.c" /* yacc.c:1646 */ break; case 77: -#line 1110 "awkgram.y" /* yacc.c:1646 */ +#line 1109 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_push_re; (yyval) = (yyvsp[0]); } -#line 2953 "awkgram.c" /* yacc.c:1646 */ +#line 2952 "awkgram.c" /* yacc.c:1646 */ break; case 78: -#line 1118 "awkgram.y" /* yacc.c:1646 */ +#line 1117 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2959 "awkgram.c" /* yacc.c:1646 */ +#line 2958 "awkgram.c" /* yacc.c:1646 */ break; case 79: -#line 1120 "awkgram.y" /* yacc.c:1646 */ +#line 1119 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2965 "awkgram.c" /* yacc.c:1646 */ +#line 2964 "awkgram.c" /* yacc.c:1646 */ break; case 81: -#line 1130 "awkgram.y" /* yacc.c:1646 */ +#line 1129 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 2973 "awkgram.c" /* yacc.c:1646 */ +#line 2972 "awkgram.c" /* yacc.c:1646 */ break; case 82: -#line 1137 "awkgram.y" /* yacc.c:1646 */ +#line 1136 "awkgram.y" /* yacc.c:1646 */ { in_print = false; in_parens = 0; (yyval) = NULL; } -#line 2983 "awkgram.c" /* yacc.c:1646 */ +#line 2982 "awkgram.c" /* yacc.c:1646 */ break; case 83: -#line 1142 "awkgram.y" /* yacc.c:1646 */ +#line 1141 "awkgram.y" /* yacc.c:1646 */ { in_print = false; in_parens = 0; } -#line 2989 "awkgram.c" /* yacc.c:1646 */ +#line 2988 "awkgram.c" /* yacc.c:1646 */ break; case 84: -#line 1143 "awkgram.y" /* yacc.c:1646 */ +#line 1142 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-2])->redir_type == redirect_twoway && (yyvsp[0])->lasti->opcode == Op_K_getline_redir @@ -2997,136 +2996,136 @@ regular_print: yyerror(_("multistage two-way pipelines don't work")); (yyval) = list_prepend((yyvsp[0]), (yyvsp[-2])); } -#line 3001 "awkgram.c" /* yacc.c:1646 */ +#line 3000 "awkgram.c" /* yacc.c:1646 */ break; case 85: -#line 1154 "awkgram.y" /* yacc.c:1646 */ +#line 1153 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_condition((yyvsp[-3]), (yyvsp[-5]), (yyvsp[0]), NULL, NULL); } -#line 3009 "awkgram.c" /* yacc.c:1646 */ +#line 3008 "awkgram.c" /* yacc.c:1646 */ break; case 86: -#line 1159 "awkgram.y" /* yacc.c:1646 */ +#line 1158 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_condition((yyvsp[-6]), (yyvsp[-8]), (yyvsp[-3]), (yyvsp[-2]), (yyvsp[0])); } -#line 3017 "awkgram.c" /* yacc.c:1646 */ +#line 3016 "awkgram.c" /* yacc.c:1646 */ break; case 91: -#line 1176 "awkgram.y" /* yacc.c:1646 */ +#line 1175 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3023 "awkgram.c" /* yacc.c:1646 */ +#line 3022 "awkgram.c" /* yacc.c:1646 */ break; case 92: -#line 1178 "awkgram.y" /* yacc.c:1646 */ +#line 1177 "awkgram.y" /* yacc.c:1646 */ { bcfree((yyvsp[-1])); (yyval) = (yyvsp[0]); } -#line 3032 "awkgram.c" /* yacc.c:1646 */ +#line 3031 "awkgram.c" /* yacc.c:1646 */ break; case 93: -#line 1186 "awkgram.y" /* yacc.c:1646 */ +#line 1185 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3038 "awkgram.c" /* yacc.c:1646 */ +#line 3037 "awkgram.c" /* yacc.c:1646 */ break; case 94: -#line 1188 "awkgram.y" /* yacc.c:1646 */ +#line 1187 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]) ; } -#line 3044 "awkgram.c" /* yacc.c:1646 */ +#line 3043 "awkgram.c" /* yacc.c:1646 */ break; case 95: -#line 1193 "awkgram.y" /* yacc.c:1646 */ +#line 1192 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->param_count = 0; (yyval) = list_create((yyvsp[0])); } -#line 3053 "awkgram.c" /* yacc.c:1646 */ +#line 3052 "awkgram.c" /* yacc.c:1646 */ break; case 96: -#line 1198 "awkgram.y" /* yacc.c:1646 */ +#line 1197 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->param_count = (yyvsp[-2])->lasti->param_count + 1; (yyval) = list_append((yyvsp[-2]), (yyvsp[0])); yyerrok; } -#line 3063 "awkgram.c" /* yacc.c:1646 */ +#line 3062 "awkgram.c" /* yacc.c:1646 */ break; case 97: -#line 1204 "awkgram.y" /* yacc.c:1646 */ +#line 1203 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3069 "awkgram.c" /* yacc.c:1646 */ +#line 3068 "awkgram.c" /* yacc.c:1646 */ break; case 98: -#line 1206 "awkgram.y" /* yacc.c:1646 */ +#line 1205 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3075 "awkgram.c" /* yacc.c:1646 */ +#line 3074 "awkgram.c" /* yacc.c:1646 */ break; case 99: -#line 1208 "awkgram.y" /* yacc.c:1646 */ +#line 1207 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-2]); } -#line 3081 "awkgram.c" /* yacc.c:1646 */ +#line 3080 "awkgram.c" /* yacc.c:1646 */ break; case 100: -#line 1214 "awkgram.y" /* yacc.c:1646 */ +#line 1213 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3087 "awkgram.c" /* yacc.c:1646 */ +#line 3086 "awkgram.c" /* yacc.c:1646 */ break; case 101: -#line 1216 "awkgram.y" /* yacc.c:1646 */ +#line 1215 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3093 "awkgram.c" /* yacc.c:1646 */ +#line 3092 "awkgram.c" /* yacc.c:1646 */ break; case 102: -#line 1221 "awkgram.y" /* yacc.c:1646 */ +#line 1220 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3099 "awkgram.c" /* yacc.c:1646 */ +#line 3098 "awkgram.c" /* yacc.c:1646 */ break; case 103: -#line 1223 "awkgram.y" /* yacc.c:1646 */ +#line 1222 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3105 "awkgram.c" /* yacc.c:1646 */ +#line 3104 "awkgram.c" /* yacc.c:1646 */ break; case 104: -#line 1228 "awkgram.y" /* yacc.c:1646 */ +#line 1227 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_expression_list(NULL, (yyvsp[0])); } -#line 3111 "awkgram.c" /* yacc.c:1646 */ +#line 3110 "awkgram.c" /* yacc.c:1646 */ break; case 105: -#line 1230 "awkgram.y" /* yacc.c:1646 */ +#line 1229 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0])); yyerrok; } -#line 3120 "awkgram.c" /* yacc.c:1646 */ +#line 3119 "awkgram.c" /* yacc.c:1646 */ break; case 106: -#line 1235 "awkgram.y" /* yacc.c:1646 */ +#line 1234 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3126 "awkgram.c" /* yacc.c:1646 */ +#line 3125 "awkgram.c" /* yacc.c:1646 */ break; case 107: -#line 1237 "awkgram.y" /* yacc.c:1646 */ +#line 1236 "awkgram.y" /* yacc.c:1646 */ { /* * Returning the expression list instead of NULL lets @@ -3134,52 +3133,52 @@ regular_print: */ (yyval) = (yyvsp[-1]); } -#line 3138 "awkgram.c" /* yacc.c:1646 */ +#line 3137 "awkgram.c" /* yacc.c:1646 */ break; case 108: -#line 1245 "awkgram.y" /* yacc.c:1646 */ +#line 1244 "awkgram.y" /* yacc.c:1646 */ { /* Ditto */ (yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0])); } -#line 3147 "awkgram.c" /* yacc.c:1646 */ +#line 3146 "awkgram.c" /* yacc.c:1646 */ break; case 109: -#line 1250 "awkgram.y" /* yacc.c:1646 */ +#line 1249 "awkgram.y" /* yacc.c:1646 */ { /* Ditto */ (yyval) = (yyvsp[-2]); } -#line 3156 "awkgram.c" /* yacc.c:1646 */ +#line 3155 "awkgram.c" /* yacc.c:1646 */ break; case 110: -#line 1259 "awkgram.y" /* yacc.c:1646 */ +#line 1258 "awkgram.y" /* yacc.c:1646 */ { if (do_lint && (yyvsp[0])->lasti->opcode == Op_match_rec) lintwarn_ln((yyvsp[-1])->source_line, _("regular expression on right of assignment")); (yyval) = mk_assignment((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3167 "awkgram.c" /* yacc.c:1646 */ +#line 3166 "awkgram.c" /* yacc.c:1646 */ break; case 111: -#line 1266 "awkgram.y" /* yacc.c:1646 */ +#line 1265 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3173 "awkgram.c" /* yacc.c:1646 */ +#line 3172 "awkgram.c" /* yacc.c:1646 */ break; case 112: -#line 1268 "awkgram.y" /* yacc.c:1646 */ +#line 1267 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3179 "awkgram.c" /* yacc.c:1646 */ +#line 3178 "awkgram.c" /* yacc.c:1646 */ break; case 113: -#line 1270 "awkgram.y" /* yacc.c:1646 */ +#line 1269 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-2])->lasti->opcode == Op_match_rec) warning_ln((yyvsp[-1])->source_line, @@ -3195,11 +3194,11 @@ regular_print: (yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1])); } } -#line 3199 "awkgram.c" /* yacc.c:1646 */ +#line 3198 "awkgram.c" /* yacc.c:1646 */ break; case 114: -#line 1286 "awkgram.y" /* yacc.c:1646 */ +#line 1285 "awkgram.y" /* yacc.c:1646 */ { if (do_lint_old) warning_ln((yyvsp[-1])->source_line, @@ -3209,91 +3208,91 @@ regular_print: (yyvsp[-1])->expr_count = 1; (yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1])); } -#line 3213 "awkgram.c" /* yacc.c:1646 */ +#line 3212 "awkgram.c" /* yacc.c:1646 */ break; case 115: -#line 1296 "awkgram.y" /* yacc.c:1646 */ +#line 1295 "awkgram.y" /* yacc.c:1646 */ { if (do_lint && (yyvsp[0])->lasti->opcode == Op_match_rec) lintwarn_ln((yyvsp[-1])->source_line, _("regular expression on right of comparison")); (yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1])); } -#line 3224 "awkgram.c" /* yacc.c:1646 */ +#line 3223 "awkgram.c" /* yacc.c:1646 */ break; case 116: -#line 1303 "awkgram.y" /* yacc.c:1646 */ +#line 1302 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_condition((yyvsp[-4]), (yyvsp[-3]), (yyvsp[-2]), (yyvsp[-1]), (yyvsp[0])); } -#line 3230 "awkgram.c" /* yacc.c:1646 */ +#line 3229 "awkgram.c" /* yacc.c:1646 */ break; case 117: -#line 1305 "awkgram.y" /* yacc.c:1646 */ +#line 1304 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3236 "awkgram.c" /* yacc.c:1646 */ +#line 3235 "awkgram.c" /* yacc.c:1646 */ break; case 118: -#line 1310 "awkgram.y" /* yacc.c:1646 */ +#line 1309 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3242 "awkgram.c" /* yacc.c:1646 */ +#line 3241 "awkgram.c" /* yacc.c:1646 */ break; case 119: -#line 1312 "awkgram.y" /* yacc.c:1646 */ +#line 1311 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3248 "awkgram.c" /* yacc.c:1646 */ +#line 3247 "awkgram.c" /* yacc.c:1646 */ break; case 120: -#line 1314 "awkgram.y" /* yacc.c:1646 */ +#line 1313 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_assign_quotient; (yyval) = (yyvsp[0]); } -#line 3257 "awkgram.c" /* yacc.c:1646 */ +#line 3256 "awkgram.c" /* yacc.c:1646 */ break; case 121: -#line 1322 "awkgram.y" /* yacc.c:1646 */ +#line 1321 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3263 "awkgram.c" /* yacc.c:1646 */ +#line 3262 "awkgram.c" /* yacc.c:1646 */ break; case 122: -#line 1324 "awkgram.y" /* yacc.c:1646 */ +#line 1323 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3269 "awkgram.c" /* yacc.c:1646 */ +#line 3268 "awkgram.c" /* yacc.c:1646 */ break; case 123: -#line 1329 "awkgram.y" /* yacc.c:1646 */ +#line 1328 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3275 "awkgram.c" /* yacc.c:1646 */ +#line 3274 "awkgram.c" /* yacc.c:1646 */ break; case 124: -#line 1331 "awkgram.y" /* yacc.c:1646 */ +#line 1330 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3281 "awkgram.c" /* yacc.c:1646 */ +#line 3280 "awkgram.c" /* yacc.c:1646 */ break; case 125: -#line 1336 "awkgram.y" /* yacc.c:1646 */ +#line 1335 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3287 "awkgram.c" /* yacc.c:1646 */ +#line 3286 "awkgram.c" /* yacc.c:1646 */ break; case 126: -#line 1338 "awkgram.y" /* yacc.c:1646 */ +#line 1337 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3293 "awkgram.c" /* yacc.c:1646 */ +#line 3292 "awkgram.c" /* yacc.c:1646 */ break; case 127: -#line 1340 "awkgram.y" /* yacc.c:1646 */ +#line 1339 "awkgram.y" /* yacc.c:1646 */ { int count = 2; bool is_simple_var = false; @@ -3340,47 +3339,47 @@ regular_print: max_args = count; } } -#line 3344 "awkgram.c" /* yacc.c:1646 */ +#line 3343 "awkgram.c" /* yacc.c:1646 */ break; case 129: -#line 1392 "awkgram.y" /* yacc.c:1646 */ +#line 1391 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3350 "awkgram.c" /* yacc.c:1646 */ +#line 3349 "awkgram.c" /* yacc.c:1646 */ break; case 130: -#line 1394 "awkgram.y" /* yacc.c:1646 */ +#line 1393 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3356 "awkgram.c" /* yacc.c:1646 */ +#line 3355 "awkgram.c" /* yacc.c:1646 */ break; case 131: -#line 1396 "awkgram.y" /* yacc.c:1646 */ +#line 1395 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3362 "awkgram.c" /* yacc.c:1646 */ +#line 3361 "awkgram.c" /* yacc.c:1646 */ break; case 132: -#line 1398 "awkgram.y" /* yacc.c:1646 */ +#line 1397 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3368 "awkgram.c" /* yacc.c:1646 */ +#line 3367 "awkgram.c" /* yacc.c:1646 */ break; case 133: -#line 1400 "awkgram.y" /* yacc.c:1646 */ +#line 1399 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3374 "awkgram.c" /* yacc.c:1646 */ +#line 3373 "awkgram.c" /* yacc.c:1646 */ break; case 134: -#line 1402 "awkgram.y" /* yacc.c:1646 */ +#line 1401 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3380 "awkgram.c" /* yacc.c:1646 */ +#line 3379 "awkgram.c" /* yacc.c:1646 */ break; case 135: -#line 1404 "awkgram.y" /* yacc.c:1646 */ +#line 1403 "awkgram.y" /* yacc.c:1646 */ { /* * In BEGINFILE/ENDFILE, allow `getline [var] < file' @@ -3394,29 +3393,29 @@ regular_print: _("non-redirected `getline' undefined inside END action")); (yyval) = mk_getline((yyvsp[-2]), (yyvsp[-1]), (yyvsp[0]), redirect_input); } -#line 3398 "awkgram.c" /* yacc.c:1646 */ +#line 3397 "awkgram.c" /* yacc.c:1646 */ break; case 136: -#line 1418 "awkgram.y" /* yacc.c:1646 */ +#line 1417 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postincrement; (yyval) = mk_assignment((yyvsp[-1]), NULL, (yyvsp[0])); } -#line 3407 "awkgram.c" /* yacc.c:1646 */ +#line 3406 "awkgram.c" /* yacc.c:1646 */ break; case 137: -#line 1423 "awkgram.y" /* yacc.c:1646 */ +#line 1422 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postdecrement; (yyval) = mk_assignment((yyvsp[-1]), NULL, (yyvsp[0])); } -#line 3416 "awkgram.c" /* yacc.c:1646 */ +#line 3415 "awkgram.c" /* yacc.c:1646 */ break; case 138: -#line 1428 "awkgram.y" /* yacc.c:1646 */ +#line 1427 "awkgram.y" /* yacc.c:1646 */ { if (do_lint_old) { warning_ln((yyvsp[-1])->source_line, @@ -3436,64 +3435,64 @@ regular_print: (yyval) = list_append(list_merge(t, (yyvsp[0])), (yyvsp[-1])); } } -#line 3440 "awkgram.c" /* yacc.c:1646 */ +#line 3439 "awkgram.c" /* yacc.c:1646 */ break; case 139: -#line 1453 "awkgram.y" /* yacc.c:1646 */ +#line 1452 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_getline((yyvsp[-1]), (yyvsp[0]), (yyvsp[-3]), (yyvsp[-2])->redir_type); bcfree((yyvsp[-2])); } -#line 3449 "awkgram.c" /* yacc.c:1646 */ +#line 3448 "awkgram.c" /* yacc.c:1646 */ break; case 140: -#line 1459 "awkgram.y" /* yacc.c:1646 */ +#line 1458 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3455 "awkgram.c" /* yacc.c:1646 */ +#line 3454 "awkgram.c" /* yacc.c:1646 */ break; case 141: -#line 1461 "awkgram.y" /* yacc.c:1646 */ +#line 1460 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3461 "awkgram.c" /* yacc.c:1646 */ +#line 3460 "awkgram.c" /* yacc.c:1646 */ break; case 142: -#line 1463 "awkgram.y" /* yacc.c:1646 */ +#line 1462 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3467 "awkgram.c" /* yacc.c:1646 */ +#line 3466 "awkgram.c" /* yacc.c:1646 */ break; case 143: -#line 1465 "awkgram.y" /* yacc.c:1646 */ +#line 1464 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3473 "awkgram.c" /* yacc.c:1646 */ +#line 3472 "awkgram.c" /* yacc.c:1646 */ break; case 144: -#line 1467 "awkgram.y" /* yacc.c:1646 */ +#line 1466 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3479 "awkgram.c" /* yacc.c:1646 */ +#line 3478 "awkgram.c" /* yacc.c:1646 */ break; case 145: -#line 1469 "awkgram.y" /* yacc.c:1646 */ +#line 1468 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3485 "awkgram.c" /* yacc.c:1646 */ +#line 3484 "awkgram.c" /* yacc.c:1646 */ break; case 146: -#line 1474 "awkgram.y" /* yacc.c:1646 */ +#line 1473 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_create((yyvsp[0])); } -#line 3493 "awkgram.c" /* yacc.c:1646 */ +#line 3492 "awkgram.c" /* yacc.c:1646 */ break; case 147: -#line 1478 "awkgram.y" /* yacc.c:1646 */ +#line 1477 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[0])->opcode == Op_match_rec) { (yyvsp[0])->opcode = Op_nomatch; @@ -3525,37 +3524,37 @@ regular_print: } } } -#line 3529 "awkgram.c" /* yacc.c:1646 */ +#line 3528 "awkgram.c" /* yacc.c:1646 */ break; case 148: -#line 1510 "awkgram.y" /* yacc.c:1646 */ +#line 1509 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3535 "awkgram.c" /* yacc.c:1646 */ +#line 3534 "awkgram.c" /* yacc.c:1646 */ break; case 149: -#line 1512 "awkgram.y" /* yacc.c:1646 */ +#line 1511 "awkgram.y" /* yacc.c:1646 */ { (yyval) = snode((yyvsp[-1]), (yyvsp[-3])); if ((yyval) == NULL) YYABORT; } -#line 3545 "awkgram.c" /* yacc.c:1646 */ +#line 3544 "awkgram.c" /* yacc.c:1646 */ break; case 150: -#line 1518 "awkgram.y" /* yacc.c:1646 */ +#line 1517 "awkgram.y" /* yacc.c:1646 */ { (yyval) = snode((yyvsp[-1]), (yyvsp[-3])); if ((yyval) == NULL) YYABORT; } -#line 3555 "awkgram.c" /* yacc.c:1646 */ +#line 3554 "awkgram.c" /* yacc.c:1646 */ break; case 151: -#line 1524 "awkgram.y" /* yacc.c:1646 */ +#line 1523 "awkgram.y" /* yacc.c:1646 */ { static bool warned = false; @@ -3568,45 +3567,45 @@ regular_print: if ((yyval) == NULL) YYABORT; } -#line 3572 "awkgram.c" /* yacc.c:1646 */ +#line 3571 "awkgram.c" /* yacc.c:1646 */ break; case 154: -#line 1539 "awkgram.y" /* yacc.c:1646 */ +#line 1538 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[-1])->opcode = Op_preincrement; (yyval) = mk_assignment((yyvsp[0]), NULL, (yyvsp[-1])); } -#line 3581 "awkgram.c" /* yacc.c:1646 */ +#line 3580 "awkgram.c" /* yacc.c:1646 */ break; case 155: -#line 1544 "awkgram.y" /* yacc.c:1646 */ +#line 1543 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[-1])->opcode = Op_predecrement; (yyval) = mk_assignment((yyvsp[0]), NULL, (yyvsp[-1])); } -#line 3590 "awkgram.c" /* yacc.c:1646 */ +#line 3589 "awkgram.c" /* yacc.c:1646 */ break; case 156: -#line 1549 "awkgram.y" /* yacc.c:1646 */ +#line 1548 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_create((yyvsp[0])); } -#line 3598 "awkgram.c" /* yacc.c:1646 */ +#line 3597 "awkgram.c" /* yacc.c:1646 */ break; case 157: -#line 1553 "awkgram.y" /* yacc.c:1646 */ +#line 1552 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_create((yyvsp[0])); } -#line 3606 "awkgram.c" /* yacc.c:1646 */ +#line 3605 "awkgram.c" /* yacc.c:1646 */ break; case 158: -#line 1557 "awkgram.y" /* yacc.c:1646 */ +#line 1556 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[0])->lasti->opcode == Op_push_i && ((yyvsp[0])->lasti->memory->flags & (STRCUR|STRING)) == 0 @@ -3621,11 +3620,11 @@ regular_print: (yyval) = list_append((yyvsp[0]), (yyvsp[-1])); } } -#line 3625 "awkgram.c" /* yacc.c:1646 */ +#line 3624 "awkgram.c" /* yacc.c:1646 */ break; case 159: -#line 1572 "awkgram.y" /* yacc.c:1646 */ +#line 1571 "awkgram.y" /* yacc.c:1646 */ { /* * was: $$ = $2 @@ -3635,20 +3634,20 @@ regular_print: (yyvsp[-1])->memory = make_number(0.0); (yyval) = list_append((yyvsp[0]), (yyvsp[-1])); } -#line 3639 "awkgram.c" /* yacc.c:1646 */ +#line 3638 "awkgram.c" /* yacc.c:1646 */ break; case 160: -#line 1585 "awkgram.y" /* yacc.c:1646 */ +#line 1584 "awkgram.y" /* yacc.c:1646 */ { func_use((yyvsp[0])->lasti->func_name, FUNC_USE); (yyval) = (yyvsp[0]); } -#line 3648 "awkgram.c" /* yacc.c:1646 */ +#line 3647 "awkgram.c" /* yacc.c:1646 */ break; case 161: -#line 1590 "awkgram.y" /* yacc.c:1646 */ +#line 1589 "awkgram.y" /* yacc.c:1646 */ { /* indirect function call */ INSTRUCTION *f, *t; @@ -3682,11 +3681,11 @@ regular_print: (yyval) = list_prepend((yyvsp[0]), t); at_seen = false; } -#line 3686 "awkgram.c" /* yacc.c:1646 */ +#line 3685 "awkgram.c" /* yacc.c:1646 */ break; case 162: -#line 1627 "awkgram.y" /* yacc.c:1646 */ +#line 1626 "awkgram.y" /* yacc.c:1646 */ { NODE *n; @@ -3711,49 +3710,49 @@ regular_print: (yyval) = list_append(t, (yyvsp[-3])); } } -#line 3715 "awkgram.c" /* yacc.c:1646 */ +#line 3714 "awkgram.c" /* yacc.c:1646 */ break; case 163: -#line 1655 "awkgram.y" /* yacc.c:1646 */ +#line 1654 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3721 "awkgram.c" /* yacc.c:1646 */ +#line 3720 "awkgram.c" /* yacc.c:1646 */ break; case 164: -#line 1657 "awkgram.y" /* yacc.c:1646 */ +#line 1656 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3727 "awkgram.c" /* yacc.c:1646 */ +#line 3726 "awkgram.c" /* yacc.c:1646 */ break; case 165: -#line 1662 "awkgram.y" /* yacc.c:1646 */ +#line 1661 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3733 "awkgram.c" /* yacc.c:1646 */ +#line 3732 "awkgram.c" /* yacc.c:1646 */ break; case 166: -#line 1664 "awkgram.y" /* yacc.c:1646 */ +#line 1663 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3739 "awkgram.c" /* yacc.c:1646 */ +#line 3738 "awkgram.c" /* yacc.c:1646 */ break; case 167: -#line 1669 "awkgram.y" /* yacc.c:1646 */ +#line 1668 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3745 "awkgram.c" /* yacc.c:1646 */ +#line 3744 "awkgram.c" /* yacc.c:1646 */ break; case 168: -#line 1671 "awkgram.y" /* yacc.c:1646 */ +#line 1670 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_merge((yyvsp[-1]), (yyvsp[0])); } -#line 3753 "awkgram.c" /* yacc.c:1646 */ +#line 3752 "awkgram.c" /* yacc.c:1646 */ break; case 169: -#line 1678 "awkgram.y" /* yacc.c:1646 */ +#line 1677 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *ip = (yyvsp[0])->lasti; int count = ip->sub_count; /* # of SUBSEP-seperated expressions */ @@ -3767,11 +3766,11 @@ regular_print: sub_counter++; /* count # of dimensions */ (yyval) = (yyvsp[0]); } -#line 3771 "awkgram.c" /* yacc.c:1646 */ +#line 3770 "awkgram.c" /* yacc.c:1646 */ break; case 170: -#line 1695 "awkgram.y" /* yacc.c:1646 */ +#line 1694 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *t = (yyvsp[-1]); if ((yyvsp[-1]) == NULL) { @@ -3785,31 +3784,31 @@ regular_print: (yyvsp[0])->sub_count = count_expressions(&t, false); (yyval) = list_append(t, (yyvsp[0])); } -#line 3789 "awkgram.c" /* yacc.c:1646 */ +#line 3788 "awkgram.c" /* yacc.c:1646 */ break; case 171: -#line 1712 "awkgram.y" /* yacc.c:1646 */ +#line 1711 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3795 "awkgram.c" /* yacc.c:1646 */ +#line 3794 "awkgram.c" /* yacc.c:1646 */ break; case 172: -#line 1714 "awkgram.y" /* yacc.c:1646 */ +#line 1713 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_merge((yyvsp[-1]), (yyvsp[0])); } -#line 3803 "awkgram.c" /* yacc.c:1646 */ +#line 3802 "awkgram.c" /* yacc.c:1646 */ break; case 173: -#line 1721 "awkgram.y" /* yacc.c:1646 */ +#line 1720 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3809 "awkgram.c" /* yacc.c:1646 */ +#line 3808 "awkgram.c" /* yacc.c:1646 */ break; case 174: -#line 1726 "awkgram.y" /* yacc.c:1646 */ +#line 1725 "awkgram.y" /* yacc.c:1646 */ { char *var_name = (yyvsp[0])->lextok; @@ -3817,22 +3816,22 @@ regular_print: (yyvsp[0])->memory = variable((yyvsp[0])->source_line, var_name, Node_var_new); (yyval) = list_create((yyvsp[0])); } -#line 3821 "awkgram.c" /* yacc.c:1646 */ +#line 3820 "awkgram.c" /* yacc.c:1646 */ break; case 175: -#line 1734 "awkgram.y" /* yacc.c:1646 */ +#line 1733 "awkgram.y" /* yacc.c:1646 */ { char *arr = (yyvsp[-1])->lextok; (yyvsp[-1])->memory = variable((yyvsp[-1])->source_line, arr, Node_var_new); (yyvsp[-1])->opcode = Op_push_array; (yyval) = list_prepend((yyvsp[0]), (yyvsp[-1])); } -#line 3832 "awkgram.c" /* yacc.c:1646 */ +#line 3831 "awkgram.c" /* yacc.c:1646 */ break; case 176: -#line 1744 "awkgram.y" /* yacc.c:1646 */ +#line 1743 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *ip = (yyvsp[0])->nexti; if (ip->opcode == Op_push @@ -3844,73 +3843,73 @@ regular_print: } else (yyval) = (yyvsp[0]); } -#line 3848 "awkgram.c" /* yacc.c:1646 */ +#line 3847 "awkgram.c" /* yacc.c:1646 */ break; case 177: -#line 1756 "awkgram.y" /* yacc.c:1646 */ +#line 1755 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_append((yyvsp[-1]), (yyvsp[-2])); if ((yyvsp[0]) != NULL) mk_assignment((yyvsp[-1]), NULL, (yyvsp[0])); } -#line 3858 "awkgram.c" /* yacc.c:1646 */ +#line 3857 "awkgram.c" /* yacc.c:1646 */ break; case 178: -#line 1765 "awkgram.y" /* yacc.c:1646 */ +#line 1764 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postincrement; } -#line 3866 "awkgram.c" /* yacc.c:1646 */ +#line 3865 "awkgram.c" /* yacc.c:1646 */ break; case 179: -#line 1769 "awkgram.y" /* yacc.c:1646 */ +#line 1768 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postdecrement; } -#line 3874 "awkgram.c" /* yacc.c:1646 */ +#line 3873 "awkgram.c" /* yacc.c:1646 */ break; case 180: -#line 1772 "awkgram.y" /* yacc.c:1646 */ +#line 1771 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3880 "awkgram.c" /* yacc.c:1646 */ +#line 3879 "awkgram.c" /* yacc.c:1646 */ break; case 182: -#line 1780 "awkgram.y" /* yacc.c:1646 */ +#line 1779 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3886 "awkgram.c" /* yacc.c:1646 */ +#line 3885 "awkgram.c" /* yacc.c:1646 */ break; case 183: -#line 1784 "awkgram.y" /* yacc.c:1646 */ +#line 1783 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3892 "awkgram.c" /* yacc.c:1646 */ +#line 3891 "awkgram.c" /* yacc.c:1646 */ break; case 186: -#line 1793 "awkgram.y" /* yacc.c:1646 */ +#line 1792 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3898 "awkgram.c" /* yacc.c:1646 */ +#line 3897 "awkgram.c" /* yacc.c:1646 */ break; case 187: -#line 1797 "awkgram.y" /* yacc.c:1646 */ +#line 1796 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); yyerrok; } -#line 3904 "awkgram.c" /* yacc.c:1646 */ +#line 3903 "awkgram.c" /* yacc.c:1646 */ break; case 188: -#line 1801 "awkgram.y" /* yacc.c:1646 */ +#line 1800 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3910 "awkgram.c" /* yacc.c:1646 */ +#line 3909 "awkgram.c" /* yacc.c:1646 */ break; -#line 3914 "awkgram.c" /* yacc.c:1646 */ +#line 3913 "awkgram.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -4138,7 +4137,7 @@ yyreturn: #endif return yyresult; } -#line 1803 "awkgram.y" /* yacc.c:1906 */ +#line 1802 "awkgram.y" /* yacc.c:1906 */ struct token { @@ -6816,7 +6815,7 @@ variable(int location, char *name, NODETYPE type) /* make_regnode --- make a regular expression node */ -static NODE * +NODE * make_regnode(int type, NODE *exp) { NODE *n; diff --git a/awkgram.y b/awkgram.y index 2be4d37c..0b3a97c9 100644 --- a/awkgram.y +++ b/awkgram.y @@ -73,7 +73,6 @@ static INSTRUCTION *mk_binary(INSTRUCTION *s1, INSTRUCTION *s2, INSTRUCTION *op) static INSTRUCTION *mk_boolean(INSTRUCTION *left, INSTRUCTION *right, INSTRUCTION *op); static INSTRUCTION *mk_assignment(INSTRUCTION *lhs, INSTRUCTION *rhs, INSTRUCTION *op); static INSTRUCTION *mk_getline(INSTRUCTION *op, INSTRUCTION *opt_var, INSTRUCTION *redir, int redirtype); -static NODE *make_regnode(int type, NODE *exp); static int count_expressions(INSTRUCTION **list, bool isarg); static INSTRUCTION *optimize_assignment(INSTRUCTION *exp); static void add_lint(INSTRUCTION *list, LINTTYPE linttype); @@ -4477,7 +4476,7 @@ variable(int location, char *name, NODETYPE type) /* make_regnode --- make a regular expression node */ -static NODE * +NODE * make_regnode(int type, NODE *exp) { NODE *n; diff --git a/builtin.c b/builtin.c index 4dd08eb1..7926a320 100644 --- a/builtin.c +++ b/builtin.c @@ -3000,7 +3000,7 @@ NODE * call_sub_func(const char *name, int nargs) { unsigned int flags = 0; - NODE *tmp; + NODE *regex, *replace; if (name[0] == 'g') { if (name[1] == 'e') @@ -3009,10 +3009,15 @@ call_sub_func(const char *name, int nargs) flags = GSUB; } - tmp = PEEK(1); - if (tmp->type == Node_val) { - flags |= LITERAL; - } + if ((flags == 0 || flags == GSUB) && nargs != 2) + fatal(_("%s: can be called indirectly only with two arguments"), name); + + replace = POP(); + + regex = POP(); /* the regex */ + regex = make_regnode(Node_regex, regex); + PUSH(regex); + PUSH(replace); return do_sub(nargs, flags); } diff --git a/indirectbuitin.awk b/indirectbuitin.awk index 26cb5cc4..8c78593c 100644 --- a/indirectbuitin.awk +++ b/indirectbuitin.awk @@ -8,12 +8,13 @@ function print_result(category, fname, builtin_result, indirect_result) } BEGIN { - fun = "sub" - x = "ff11bb" - b1 = sub("f", "q", x) - i1 = @fun("f", "q", x) + $0 = "ff11bb" + b1 = sub("f", "q") + $0 = "ff11bb" + i1 = @fun("f", "q") print_result("string", fun, b1, i1) + exit } diff --git a/interpret.h b/interpret.h index 9160d479..f9aa3115 100644 --- a/interpret.h +++ b/interpret.h @@ -1066,7 +1066,7 @@ match_re: assert(the_func != NULL); /* call it */ - if (the_func == do_sub) + if (the_func == (builtin_func_t) do_sub) r = call_sub_func(t1->stptr, arg_count); else r = the_func(arg_count); diff --git a/node.c b/node.c index 9fd4c7b9..179d272e 100644 --- a/node.c +++ b/node.c @@ -431,6 +431,13 @@ r_unref(NODE *tmp) #ifdef GAWKDEBUG if (tmp == NULL) return; + if (tmp->type == Node_regex) { + if (tmp->re_reg != NULL) + refree(tmp->re_reg); + if (tmp->re_text != NULL) + unref(tmp->re_text); + goto free_the_node; + } if ((tmp->flags & MALLOC) != 0) { if (tmp->valref > 1) { tmp->valref--; @@ -447,6 +454,7 @@ r_unref(NODE *tmp) mpfr_unset(tmp); free_wstr(tmp); +free_the_node: freenode(tmp); } -- cgit v1.2.1 From 2ee1a928483f4fe4f594aebc5c1f8da1253c28b9 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 31 Mar 2015 06:23:04 +0300 Subject: Further improvements. sub/gsub working. --- ChangeLog | 7 ++++++ awk.h | 1 + builtin.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++-------- eval.c | 2 +- indirectbuitin.awk | 54 ++++++++++++++++++++++++-------------------- node.c | 1 + 6 files changed, 97 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8610df82..47ef45ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2015-03-31 Arnold D. Robbins + + * awk.h (r_get_field): Declare. + * builtin.c (call_sub_func): Rearrange the stack to be what + the buitin function expects. + * eval.c (r_get_field): Make extern. + 2015-03-24 Arnold D. Robbins * awkgram.y (make_regnode): Make extern. diff --git a/awk.h b/awk.h index f23977fb..1205401b 100644 --- a/awk.h +++ b/awk.h @@ -1408,6 +1408,7 @@ extern NODE **r_get_lhs(NODE *n, bool reference); extern STACK_ITEM *grow_stack(void); extern void dump_fcall_stack(FILE *fp); extern int register_exec_hook(Func_pre_exec preh, Func_post_exec posth); +extern NODE **r_get_field(NODE *n, Func_ptr *assign, bool reference); /* ext.c */ extern NODE *do_ext(int nargs); void load_ext(const char *lib_name); /* temporary */ diff --git a/builtin.c b/builtin.c index 7926a320..c222ce78 100644 --- a/builtin.c +++ b/builtin.c @@ -3000,7 +3000,10 @@ NODE * call_sub_func(const char *name, int nargs) { unsigned int flags = 0; - NODE *regex, *replace; + NODE *regex, *replace, *glob_flag; + NODE **lhs, *rhs; + NODE *zero = make_number(0.0); + NODE *result; if (name[0] == 'g') { if (name[1] == 'e') @@ -3009,17 +3012,62 @@ call_sub_func(const char *name, int nargs) flags = GSUB; } - if ((flags == 0 || flags == GSUB) && nargs != 2) - fatal(_("%s: can be called indirectly only with two arguments"), name); + if (flags == 0 || flags == GSUB) { + /* sub or gsub */ + if (nargs != 2) + fatal(_("%s: can be called indirectly only with two arguments"), name); - replace = POP(); + replace = POP_STRING(); + regex = POP(); /* the regex */ + /* + * push regex + * push replace + * push $0 + */ + regex = make_regnode(Node_regex, regex); + PUSH(regex); + PUSH(replace); + lhs = r_get_field(zero, (Func_ptr *) 0, true); + nargs++; + PUSH_ADDRESS(lhs); + } else { + /* gensub */ + if (nargs == 4) + rhs = POP(); + else + rhs = NULL; + glob_flag = POP_STRING(); + replace = POP_STRING(); + regex = POP(); /* the regex */ + /* + * push regex + * push replace + * push glob_flag + * if (nargs = 3) { + * push $0 + * nargs++ + * } + */ + regex = make_regnode(Node_regex, regex); + PUSH(regex); + PUSH(replace); + PUSH(glob_flag); + if (rhs == NULL) { + lhs = r_get_field(zero, (Func_ptr *) 0, true); + rhs = *lhs; + UPREF(rhs); + PUSH(rhs); + nargs++; + } + PUSH(rhs); + } - regex = POP(); /* the regex */ - regex = make_regnode(Node_regex, regex); - PUSH(regex); - PUSH(replace); - return do_sub(nargs, flags); + unref(zero); + result = do_sub(nargs, flags); + if (flags != GENSUB) + reset_record(); + return result; } diff --git a/eval.c b/eval.c index 2ba79956..5f66763a 100644 --- a/eval.c +++ b/eval.c @@ -1180,7 +1180,7 @@ r_get_lhs(NODE *n, bool reference) /* r_get_field --- get the address of a field node */ -static inline NODE ** +NODE ** r_get_field(NODE *n, Func_ptr *assign, bool reference) { long field_num; diff --git a/indirectbuitin.awk b/indirectbuitin.awk index 8c78593c..de3d5ccd 100644 --- a/indirectbuitin.awk +++ b/indirectbuitin.awk @@ -7,16 +7,6 @@ function print_result(category, fname, builtin_result, indirect_result) builtin_result, indirect_result) } -BEGIN { - fun = "sub" - $0 = "ff11bb" - b1 = sub("f", "q") - $0 = "ff11bb" - i1 = @fun("f", "q") - print_result("string", fun, b1, i1) - exit -} - BEGIN { # math functions @@ -101,16 +91,24 @@ BEGIN { # string functions -# fun = "gensub" -# b1 = gensub("f", "q","g", "ff11bb") -# i1 = @fun("f", "q", "g", "ff11bb") -# print_result("string", fun, b1, i1) + fun = "gensub" + b1 = gensub("f", "q", "g", "ff11bb") + i1 = @fun("f", "q", "g", "ff11bb") + print_result("string", fun, b1, i1) -# fun = "gsub" -# x = "ff11bb" -# b1 = gsub("f", "q", x) -# i1 = @fun("f", "q", x) -# print_result("string", fun, b1, i1) + fun = "gsub" + $0 = "ff11bb" + b1 = gsub("f", "q") + b2 = $0 + $0 = "ff11bb" + i1 = @fun("f", "q") + i2 = $0 + print_result("string", fun, b1, i1) + if (b2 != i2) { + printf("string: %s: fail: $0 (%s) != $0 (%s)\n", + fun, b2, i2) + exit 1 + } fun = "index" b1 = index("hi, how are you", "how") @@ -143,10 +141,18 @@ BEGIN { print_result("string", fun, b1, i1) fun = "sub" - x = "ff11bb" - b1 = sub("f", "q", x) - i1 = @fun("f", "q", x) + $0 = "ff11bb" + b1 = sub("f", "q") + b2 = $0 + $0 = "ff11bb" + i1 = @fun("f", "q") + i2 = $0 print_result("string", fun, b1, i1) + if (b2 != i2) { + printf("string: %s: fail: $0 (%s) != $0 (%s)\n", + fun, b2, i2) + exit 1 + } fun = "substr" b1 = substr("0xdeadbeef", 7, 4) @@ -210,12 +216,12 @@ BEGIN { data2[data[i]] = i fun = "asorti" - asort(data2, newdata) + asorti(data2, newdata) @fun(data2, newdata2) print_result("array", fun, b1, i1) for (i in newdata) { if (! (i in newdata2) || newdata[i] != newdata2[i]) { - print fun ": failed, index", i + print fun ": failed, index", i, "value", newdata[i], newdata2[i] exit } } diff --git a/node.c b/node.c index 179d272e..7a1d99f6 100644 --- a/node.c +++ b/node.c @@ -432,6 +432,7 @@ r_unref(NODE *tmp) if (tmp == NULL) return; if (tmp->type == Node_regex) { +fprintf(stderr, "got here!\n"); fflush(stderr); if (tmp->re_reg != NULL) refree(tmp->re_reg); if (tmp->re_text != NULL) -- cgit v1.2.1 From 2bdaa6b89e00984d79305ba1066cf98c5674b556 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 31 Mar 2015 06:24:55 +0300 Subject: Minor doc edits. --- doc/ChangeLog | 4 + doc/gawk.info | 916 ++++++++++++++++++++++++++++---------------------------- doc/gawk.texi | 12 +- doc/gawktexi.in | 12 +- 4 files changed, 479 insertions(+), 465 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index f4a6f19b..08c91bd7 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2015-03-31 Arnold D. Robbins + + * gawktexi.in: Minor edits. + 2015-03-27 Arnold D. Robbins * gawktexi.in: Minor edits. diff --git a/doc/gawk.info b/doc/gawk.info index d0312ec6..a208f834 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -6005,11 +6005,11 @@ Auto-set::): PROCINFO["INPUT_NAME", "RETRY"] = 1 - When this element exists, `gawk' checks the value of the system -`errno' variable when an I/O error occurs. If `errno' indicates a -subsequent I/O attempt may succeed, `getline' instead returns -2 and -further calls to `getline' may succeed. This applies to the `errno' -values `EAGAIN', `EWOULDBLOCK', `EINTR', or `ETIMEDOUT'. + When this element exists, `gawk' checks the value of the system (C +language) `errno' variable when an I/O error occurs. If `errno' +indicates a subsequent I/O attempt may succeed, `getline' instead +returns -2 and further calls to `getline' may succeed. This applies to +the `errno' values `EAGAIN', `EWOULDBLOCK', `EINTR', or `ETIMEDOUT'. This feature is useful in conjunction with `PROCINFO["INPUT_NAME", "READ_TIMEOUT"]' or situations where a file descriptor has been @@ -26259,15 +26259,17 @@ project. * GD graphics library extension + * MPFR library extension (this provides access to a number of MPFR + functions that `gawk''s native MPFR support does not) + * PDF extension * PostgreSQL extension - * MPFR library extension (this provides access to a number of MPFR - functions that `gawk''s native MPFR support does not) - * Redis extension + * Select extension + * XML parser extension, using the Expat (http://expat.sourceforge.net) XML parsing library @@ -33053,7 +33055,7 @@ Index (line 99) * exp: Numeric Functions. (line 33) * expand utility: Very Simple. (line 73) -* Expat XML parser library: gawkextlib. (line 35) +* Expat XML parser library: gawkextlib. (line 37) * exponent: Numeric Functions. (line 33) * expressions: Expressions. (line 6) * expressions, as patterns: Expression Patterns. (line 6) @@ -33473,7 +33475,7 @@ Index * git utility <2>: Accessing The Source. (line 10) * git utility <3>: Other Versions. (line 29) -* git utility: gawkextlib. (line 29) +* git utility: gawkextlib. (line 31) * Git, use of for gawk source code: Derived Files. (line 6) * GNITS mailing list: Acknowledgments. (line 52) * GNU awk, See gawk: Preface. (line 51) @@ -34997,452 +34999,452 @@ Ref: table-getline-variants261262 Node: Read Timeout262091 Ref: Read Timeout-Footnote-1265994 Node: Retrying Input266052 -Node: Command-line directories267238 -Node: Input Summary268145 -Node: Input Exercises271530 -Node: Printing272258 -Node: Print274093 -Node: Print Examples275550 -Node: Output Separators278329 -Node: OFMT280347 -Node: Printf281702 -Node: Basic Printf282487 -Node: Control Letters284059 -Node: Format Modifiers288044 -Node: Printf Examples294050 -Node: Redirection296536 -Node: Special FD303374 -Ref: Special FD-Footnote-1306540 -Node: Special Files306614 -Node: Other Inherited Files307231 -Node: Special Network308231 -Node: Special Caveats309093 -Node: Close Files And Pipes310042 -Ref: Close Files And Pipes-Footnote-1317227 -Ref: Close Files And Pipes-Footnote-2317375 -Node: Nonfatal317525 -Node: Output Summary319850 -Node: Output Exercises321071 -Node: Expressions321751 -Node: Values322940 -Node: Constants323617 -Node: Scalar Constants324308 -Ref: Scalar Constants-Footnote-1325170 -Node: Nondecimal-numbers325420 -Node: Regexp Constants328430 -Node: Using Constant Regexps328956 -Node: Variables332119 -Node: Using Variables332776 -Node: Assignment Options334687 -Node: Conversion336562 -Node: Strings And Numbers337086 -Ref: Strings And Numbers-Footnote-1340151 -Node: Locale influences conversions340260 -Ref: table-locale-affects343006 -Node: All Operators343598 -Node: Arithmetic Ops344227 -Node: Concatenation346732 -Ref: Concatenation-Footnote-1349551 -Node: Assignment Ops349658 -Ref: table-assign-ops354637 -Node: Increment Ops355947 -Node: Truth Values and Conditions359378 -Node: Truth Values360461 -Node: Typing and Comparison361510 -Node: Variable Typing362326 -Node: Comparison Operators365993 -Ref: table-relational-ops366403 -Node: POSIX String Comparison369898 -Ref: POSIX String Comparison-Footnote-1370970 -Node: Boolean Ops371109 -Ref: Boolean Ops-Footnote-1375587 -Node: Conditional Exp375678 -Node: Function Calls377416 -Node: Precedence381296 -Node: Locales384956 -Node: Expressions Summary386588 -Node: Patterns and Actions389159 -Node: Pattern Overview390279 -Node: Regexp Patterns391958 -Node: Expression Patterns392501 -Node: Ranges396281 -Node: BEGIN/END399388 -Node: Using BEGIN/END400149 -Ref: Using BEGIN/END-Footnote-1402885 -Node: I/O And BEGIN/END402991 -Node: BEGINFILE/ENDFILE405306 -Node: Empty408203 -Node: Using Shell Variables408520 -Node: Action Overview410793 -Node: Statements413119 -Node: If Statement414967 -Node: While Statement416462 -Node: Do Statement418490 -Node: For Statement419638 -Node: Switch Statement422796 -Node: Break Statement425178 -Node: Continue Statement427271 -Node: Next Statement429098 -Node: Nextfile Statement431479 -Node: Exit Statement434107 -Node: Built-in Variables436518 -Node: User-modified437651 -Ref: User-modified-Footnote-1445285 -Node: Auto-set445347 -Ref: Auto-set-Footnote-1459580 -Ref: Auto-set-Footnote-2459785 -Node: ARGC and ARGV459841 -Node: Pattern Action Summary464059 -Node: Arrays466492 -Node: Array Basics467821 -Node: Array Intro468665 -Ref: figure-array-elements470602 -Ref: Array Intro-Footnote-1473225 -Node: Reference to Elements473353 -Node: Assigning Elements475815 -Node: Array Example476306 -Node: Scanning an Array478065 -Node: Controlling Scanning481088 -Ref: Controlling Scanning-Footnote-1486482 -Node: Numeric Array Subscripts486798 -Node: Uninitialized Subscripts488983 -Node: Delete490600 -Ref: Delete-Footnote-1493349 -Node: Multidimensional493406 -Node: Multiscanning496503 -Node: Arrays of Arrays498092 -Node: Arrays Summary502846 -Node: Functions504937 -Node: Built-in505976 -Node: Calling Built-in507054 -Node: Numeric Functions509049 -Ref: Numeric Functions-Footnote-1513867 -Ref: Numeric Functions-Footnote-2514224 -Ref: Numeric Functions-Footnote-3514272 -Node: String Functions514544 -Ref: String Functions-Footnote-1538045 -Ref: String Functions-Footnote-2538174 -Ref: String Functions-Footnote-3538422 -Node: Gory Details538509 -Ref: table-sub-escapes540290 -Ref: table-sub-proposed541805 -Ref: table-posix-sub543167 -Ref: table-gensub-escapes544704 -Ref: Gory Details-Footnote-1545537 -Node: I/O Functions545688 -Ref: I/O Functions-Footnote-1552924 -Node: Time Functions553071 -Ref: Time Functions-Footnote-1563580 -Ref: Time Functions-Footnote-2563648 -Ref: Time Functions-Footnote-3563806 -Ref: Time Functions-Footnote-4563917 -Ref: Time Functions-Footnote-5564029 -Ref: Time Functions-Footnote-6564256 -Node: Bitwise Functions564522 -Ref: table-bitwise-ops565084 -Ref: Bitwise Functions-Footnote-1569412 -Node: Type Functions569584 -Node: I18N Functions570736 -Node: User-defined572383 -Node: Definition Syntax573188 -Ref: Definition Syntax-Footnote-1578847 -Node: Function Example578918 -Ref: Function Example-Footnote-1581839 -Node: Function Caveats581861 -Node: Calling A Function582379 -Node: Variable Scope583337 -Node: Pass By Value/Reference586330 -Node: Return Statement589827 -Node: Dynamic Typing592806 -Node: Indirect Calls593735 -Ref: Indirect Calls-Footnote-1603600 -Node: Functions Summary603728 -Node: Library Functions606430 -Ref: Library Functions-Footnote-1610038 -Ref: Library Functions-Footnote-2610181 -Node: Library Names610352 -Ref: Library Names-Footnote-1613810 -Ref: Library Names-Footnote-2614033 -Node: General Functions614119 -Node: Strtonum Function615222 -Node: Assert Function618244 -Node: Round Function621568 -Node: Cliff Random Function623109 -Node: Ordinal Functions624125 -Ref: Ordinal Functions-Footnote-1627188 -Ref: Ordinal Functions-Footnote-2627440 -Node: Join Function627651 -Ref: Join Function-Footnote-1629421 -Node: Getlocaltime Function629621 -Node: Readfile Function633365 -Node: Shell Quoting635337 -Node: Data File Management636738 -Node: Filetrans Function637370 -Node: Rewind Function641466 -Node: File Checking642852 -Ref: File Checking-Footnote-1644185 -Node: Empty Files644386 -Node: Ignoring Assigns646365 -Node: Getopt Function647915 -Ref: Getopt Function-Footnote-1659379 -Node: Passwd Functions659579 -Ref: Passwd Functions-Footnote-1668419 -Node: Group Functions668507 -Ref: Group Functions-Footnote-1676404 -Node: Walking Arrays676609 -Node: Library Functions Summary679615 -Node: Library Exercises681017 -Node: Sample Programs682297 -Node: Running Examples683067 -Node: Clones683795 -Node: Cut Program685019 -Node: Egrep Program694739 -Ref: Egrep Program-Footnote-1702242 -Node: Id Program702352 -Node: Split Program706028 -Ref: Split Program-Footnote-1709482 -Node: Tee Program709610 -Node: Uniq Program712399 -Node: Wc Program719818 -Ref: Wc Program-Footnote-1724068 -Node: Miscellaneous Programs724162 -Node: Dupword Program725375 -Node: Alarm Program727406 -Node: Translate Program732211 -Ref: Translate Program-Footnote-1736774 -Node: Labels Program737044 -Ref: Labels Program-Footnote-1740395 -Node: Word Sorting740479 -Node: History Sorting744549 -Node: Extract Program746384 -Node: Simple Sed753908 -Node: Igawk Program756978 -Ref: Igawk Program-Footnote-1771304 -Ref: Igawk Program-Footnote-2771505 -Ref: Igawk Program-Footnote-3771627 -Node: Anagram Program771742 -Node: Signature Program774803 -Node: Programs Summary776050 -Node: Programs Exercises777271 -Ref: Programs Exercises-Footnote-1781402 -Node: Advanced Features781493 -Node: Nondecimal Data783475 -Node: Array Sorting785065 -Node: Controlling Array Traversal785765 -Ref: Controlling Array Traversal-Footnote-1794131 -Node: Array Sorting Functions794249 -Ref: Array Sorting Functions-Footnote-1798135 -Node: Two-way I/O798331 -Ref: Two-way I/O-Footnote-1803276 -Ref: Two-way I/O-Footnote-2803462 -Node: TCP/IP Networking803544 -Node: Profiling806416 -Node: Advanced Features Summary814687 -Node: Internationalization816620 -Node: I18N and L10N818100 -Node: Explaining gettext818786 -Ref: Explaining gettext-Footnote-1823811 -Ref: Explaining gettext-Footnote-2823995 -Node: Programmer i18n824160 -Ref: Programmer i18n-Footnote-1829036 -Node: Translator i18n829085 -Node: String Extraction829879 -Ref: String Extraction-Footnote-1831010 -Node: Printf Ordering831096 -Ref: Printf Ordering-Footnote-1833882 -Node: I18N Portability833946 -Ref: I18N Portability-Footnote-1836402 -Node: I18N Example836465 -Ref: I18N Example-Footnote-1839268 -Node: Gawk I18N839340 -Node: I18N Summary839984 -Node: Debugger841324 -Node: Debugging842346 -Node: Debugging Concepts842787 -Node: Debugging Terms844597 -Node: Awk Debugging847169 -Node: Sample Debugging Session848075 -Node: Debugger Invocation848609 -Node: Finding The Bug849994 -Node: List of Debugger Commands856473 -Node: Breakpoint Control857805 -Node: Debugger Execution Control861482 -Node: Viewing And Changing Data864841 -Node: Execution Stack868217 -Node: Debugger Info869852 -Node: Miscellaneous Debugger Commands873897 -Node: Readline Support878898 -Node: Limitations879792 -Node: Debugging Summary881907 -Node: Arbitrary Precision Arithmetic883081 -Node: Computer Arithmetic884497 -Ref: table-numeric-ranges888074 -Ref: Computer Arithmetic-Footnote-1888598 -Node: Math Definitions888655 -Ref: table-ieee-formats891950 -Ref: Math Definitions-Footnote-1892554 -Node: MPFR features892659 -Node: FP Math Caution894330 -Ref: FP Math Caution-Footnote-1895380 -Node: Inexactness of computations895749 -Node: Inexact representation896708 -Node: Comparing FP Values898066 -Node: Errors accumulate899148 -Node: Getting Accuracy900580 -Node: Try To Round903284 -Node: Setting precision904183 -Ref: table-predefined-precision-strings904867 -Node: Setting the rounding mode906696 -Ref: table-gawk-rounding-modes907060 -Ref: Setting the rounding mode-Footnote-1910512 -Node: Arbitrary Precision Integers910691 -Ref: Arbitrary Precision Integers-Footnote-1915589 -Node: POSIX Floating Point Problems915738 -Ref: POSIX Floating Point Problems-Footnote-1919617 -Node: Floating point summary919655 -Node: Dynamic Extensions921842 -Node: Extension Intro923394 -Node: Plugin License924659 -Node: Extension Mechanism Outline925456 -Ref: figure-load-extension925884 -Ref: figure-register-new-function927364 -Ref: figure-call-new-function928368 -Node: Extension API Description930355 -Node: Extension API Functions Introduction931889 -Node: General Data Types936758 -Ref: General Data Types-Footnote-1942658 -Node: Memory Allocation Functions942957 -Ref: Memory Allocation Functions-Footnote-1945796 -Node: Constructor Functions945895 -Node: Registration Functions947634 -Node: Extension Functions948319 -Node: Exit Callback Functions950616 -Node: Extension Version String951864 -Node: Input Parsers952527 -Node: Output Wrappers962402 -Node: Two-way processors966915 -Node: Printing Messages969178 -Ref: Printing Messages-Footnote-1970254 -Node: Updating `ERRNO'970406 -Node: Requesting Values971146 -Ref: table-value-types-returned971873 -Node: Accessing Parameters972830 -Node: Symbol Table Access974064 -Node: Symbol table by name974578 -Node: Symbol table by cookie976598 -Ref: Symbol table by cookie-Footnote-1980743 -Node: Cached values980806 -Ref: Cached values-Footnote-1984302 -Node: Array Manipulation984393 -Ref: Array Manipulation-Footnote-1985483 -Node: Array Data Types985520 -Ref: Array Data Types-Footnote-1988175 -Node: Array Functions988267 -Node: Flattening Arrays992126 -Node: Creating Arrays999028 -Node: Redirection API1003799 -Node: Extension API Variables1006624 -Node: Extension Versioning1007257 -Node: Extension API Informational Variables1009148 -Node: Extension API Boilerplate1010213 -Node: Finding Extensions1014022 -Node: Extension Example1014582 -Node: Internal File Description1015354 -Node: Internal File Ops1019421 -Ref: Internal File Ops-Footnote-11031172 -Node: Using Internal File Ops1031312 -Ref: Using Internal File Ops-Footnote-11033695 -Node: Extension Samples1033968 -Node: Extension Sample File Functions1035496 -Node: Extension Sample Fnmatch1043177 -Node: Extension Sample Fork1044665 -Node: Extension Sample Inplace1045880 -Node: Extension Sample Ord1047966 -Node: Extension Sample Readdir1048802 -Ref: table-readdir-file-types1049679 -Node: Extension Sample Revout1050490 -Node: Extension Sample Rev2way1051079 -Node: Extension Sample Read write array1051819 -Node: Extension Sample Readfile1053759 -Node: Extension Sample Time1054854 -Node: Extension Sample API Tests1056202 -Node: gawkextlib1056693 -Node: Extension summary1059371 -Node: Extension Exercises1063060 -Node: Language History1064556 -Node: V7/SVR3.11066212 -Node: SVR41068365 -Node: POSIX1069799 -Node: BTL1071180 -Node: POSIX/GNU1071911 -Node: Feature History1077747 -Node: Common Extensions1091541 -Node: Ranges and Locales1092913 -Ref: Ranges and Locales-Footnote-11097532 -Ref: Ranges and Locales-Footnote-21097559 -Ref: Ranges and Locales-Footnote-31097794 -Node: Contributors1098015 -Node: History summary1103555 -Node: Installation1104934 -Node: Gawk Distribution1105880 -Node: Getting1106364 -Node: Extracting1107187 -Node: Distribution contents1108824 -Node: Unix Installation1114926 -Node: Quick Installation1115609 -Node: Shell Startup Files1118020 -Node: Additional Configuration Options1119099 -Node: Configuration Philosophy1120903 -Node: Non-Unix Installation1123272 -Node: PC Installation1123730 -Node: PC Binary Installation1125050 -Node: PC Compiling1126898 -Ref: PC Compiling-Footnote-11129919 -Node: PC Testing1130028 -Node: PC Using1131204 -Node: Cygwin1135319 -Node: MSYS1136089 -Node: VMS Installation1136590 -Node: VMS Compilation1137382 -Ref: VMS Compilation-Footnote-11138611 -Node: VMS Dynamic Extensions1138669 -Node: VMS Installation Details1140353 -Node: VMS Running1142604 -Node: VMS GNV1145444 -Node: VMS Old Gawk1146179 -Node: Bugs1146649 -Node: Other Versions1150538 -Node: Installation summary1156972 -Node: Notes1158031 -Node: Compatibility Mode1158896 -Node: Additions1159678 -Node: Accessing The Source1160603 -Node: Adding Code1162038 -Node: New Ports1168195 -Node: Derived Files1172677 -Ref: Derived Files-Footnote-11178152 -Ref: Derived Files-Footnote-21178186 -Ref: Derived Files-Footnote-31178782 -Node: Future Extensions1178896 -Node: Implementation Limitations1179502 -Node: Extension Design1180750 -Node: Old Extension Problems1181904 -Ref: Old Extension Problems-Footnote-11183421 -Node: Extension New Mechanism Goals1183478 -Ref: Extension New Mechanism Goals-Footnote-11186838 -Node: Extension Other Design Decisions1187027 -Node: Extension Future Growth1189135 -Node: Old Extension Mechanism1189971 -Node: Notes summary1191733 -Node: Basic Concepts1192919 -Node: Basic High Level1193600 -Ref: figure-general-flow1193872 -Ref: figure-process-flow1194471 -Ref: Basic High Level-Footnote-11197700 -Node: Basic Data Typing1197885 -Node: Glossary1201213 -Node: Copying1233142 -Node: GNU Free Documentation License1270698 -Node: Index1295834 +Node: Command-line directories267251 +Node: Input Summary268158 +Node: Input Exercises271543 +Node: Printing272271 +Node: Print274106 +Node: Print Examples275563 +Node: Output Separators278342 +Node: OFMT280360 +Node: Printf281715 +Node: Basic Printf282500 +Node: Control Letters284072 +Node: Format Modifiers288057 +Node: Printf Examples294063 +Node: Redirection296549 +Node: Special FD303387 +Ref: Special FD-Footnote-1306553 +Node: Special Files306627 +Node: Other Inherited Files307244 +Node: Special Network308244 +Node: Special Caveats309106 +Node: Close Files And Pipes310055 +Ref: Close Files And Pipes-Footnote-1317240 +Ref: Close Files And Pipes-Footnote-2317388 +Node: Nonfatal317538 +Node: Output Summary319863 +Node: Output Exercises321084 +Node: Expressions321764 +Node: Values322953 +Node: Constants323630 +Node: Scalar Constants324321 +Ref: Scalar Constants-Footnote-1325183 +Node: Nondecimal-numbers325433 +Node: Regexp Constants328443 +Node: Using Constant Regexps328969 +Node: Variables332132 +Node: Using Variables332789 +Node: Assignment Options334700 +Node: Conversion336575 +Node: Strings And Numbers337099 +Ref: Strings And Numbers-Footnote-1340164 +Node: Locale influences conversions340273 +Ref: table-locale-affects343019 +Node: All Operators343611 +Node: Arithmetic Ops344240 +Node: Concatenation346745 +Ref: Concatenation-Footnote-1349564 +Node: Assignment Ops349671 +Ref: table-assign-ops354650 +Node: Increment Ops355960 +Node: Truth Values and Conditions359391 +Node: Truth Values360474 +Node: Typing and Comparison361523 +Node: Variable Typing362339 +Node: Comparison Operators366006 +Ref: table-relational-ops366416 +Node: POSIX String Comparison369911 +Ref: POSIX String Comparison-Footnote-1370983 +Node: Boolean Ops371122 +Ref: Boolean Ops-Footnote-1375600 +Node: Conditional Exp375691 +Node: Function Calls377429 +Node: Precedence381309 +Node: Locales384969 +Node: Expressions Summary386601 +Node: Patterns and Actions389172 +Node: Pattern Overview390292 +Node: Regexp Patterns391971 +Node: Expression Patterns392514 +Node: Ranges396294 +Node: BEGIN/END399401 +Node: Using BEGIN/END400162 +Ref: Using BEGIN/END-Footnote-1402898 +Node: I/O And BEGIN/END403004 +Node: BEGINFILE/ENDFILE405319 +Node: Empty408216 +Node: Using Shell Variables408533 +Node: Action Overview410806 +Node: Statements413132 +Node: If Statement414980 +Node: While Statement416475 +Node: Do Statement418503 +Node: For Statement419651 +Node: Switch Statement422809 +Node: Break Statement425191 +Node: Continue Statement427284 +Node: Next Statement429111 +Node: Nextfile Statement431492 +Node: Exit Statement434120 +Node: Built-in Variables436531 +Node: User-modified437664 +Ref: User-modified-Footnote-1445298 +Node: Auto-set445360 +Ref: Auto-set-Footnote-1459593 +Ref: Auto-set-Footnote-2459798 +Node: ARGC and ARGV459854 +Node: Pattern Action Summary464072 +Node: Arrays466505 +Node: Array Basics467834 +Node: Array Intro468678 +Ref: figure-array-elements470615 +Ref: Array Intro-Footnote-1473238 +Node: Reference to Elements473366 +Node: Assigning Elements475828 +Node: Array Example476319 +Node: Scanning an Array478078 +Node: Controlling Scanning481101 +Ref: Controlling Scanning-Footnote-1486495 +Node: Numeric Array Subscripts486811 +Node: Uninitialized Subscripts488996 +Node: Delete490613 +Ref: Delete-Footnote-1493362 +Node: Multidimensional493419 +Node: Multiscanning496516 +Node: Arrays of Arrays498105 +Node: Arrays Summary502859 +Node: Functions504950 +Node: Built-in505989 +Node: Calling Built-in507067 +Node: Numeric Functions509062 +Ref: Numeric Functions-Footnote-1513880 +Ref: Numeric Functions-Footnote-2514237 +Ref: Numeric Functions-Footnote-3514285 +Node: String Functions514557 +Ref: String Functions-Footnote-1538058 +Ref: String Functions-Footnote-2538187 +Ref: String Functions-Footnote-3538435 +Node: Gory Details538522 +Ref: table-sub-escapes540303 +Ref: table-sub-proposed541818 +Ref: table-posix-sub543180 +Ref: table-gensub-escapes544717 +Ref: Gory Details-Footnote-1545550 +Node: I/O Functions545701 +Ref: I/O Functions-Footnote-1552937 +Node: Time Functions553084 +Ref: Time Functions-Footnote-1563593 +Ref: Time Functions-Footnote-2563661 +Ref: Time Functions-Footnote-3563819 +Ref: Time Functions-Footnote-4563930 +Ref: Time Functions-Footnote-5564042 +Ref: Time Functions-Footnote-6564269 +Node: Bitwise Functions564535 +Ref: table-bitwise-ops565097 +Ref: Bitwise Functions-Footnote-1569425 +Node: Type Functions569597 +Node: I18N Functions570749 +Node: User-defined572396 +Node: Definition Syntax573201 +Ref: Definition Syntax-Footnote-1578860 +Node: Function Example578931 +Ref: Function Example-Footnote-1581852 +Node: Function Caveats581874 +Node: Calling A Function582392 +Node: Variable Scope583350 +Node: Pass By Value/Reference586343 +Node: Return Statement589840 +Node: Dynamic Typing592819 +Node: Indirect Calls593748 +Ref: Indirect Calls-Footnote-1603613 +Node: Functions Summary603741 +Node: Library Functions606443 +Ref: Library Functions-Footnote-1610051 +Ref: Library Functions-Footnote-2610194 +Node: Library Names610365 +Ref: Library Names-Footnote-1613823 +Ref: Library Names-Footnote-2614046 +Node: General Functions614132 +Node: Strtonum Function615235 +Node: Assert Function618257 +Node: Round Function621581 +Node: Cliff Random Function623122 +Node: Ordinal Functions624138 +Ref: Ordinal Functions-Footnote-1627201 +Ref: Ordinal Functions-Footnote-2627453 +Node: Join Function627664 +Ref: Join Function-Footnote-1629434 +Node: Getlocaltime Function629634 +Node: Readfile Function633378 +Node: Shell Quoting635350 +Node: Data File Management636751 +Node: Filetrans Function637383 +Node: Rewind Function641479 +Node: File Checking642865 +Ref: File Checking-Footnote-1644198 +Node: Empty Files644399 +Node: Ignoring Assigns646378 +Node: Getopt Function647928 +Ref: Getopt Function-Footnote-1659392 +Node: Passwd Functions659592 +Ref: Passwd Functions-Footnote-1668432 +Node: Group Functions668520 +Ref: Group Functions-Footnote-1676417 +Node: Walking Arrays676622 +Node: Library Functions Summary679628 +Node: Library Exercises681030 +Node: Sample Programs682310 +Node: Running Examples683080 +Node: Clones683808 +Node: Cut Program685032 +Node: Egrep Program694752 +Ref: Egrep Program-Footnote-1702255 +Node: Id Program702365 +Node: Split Program706041 +Ref: Split Program-Footnote-1709495 +Node: Tee Program709623 +Node: Uniq Program712412 +Node: Wc Program719831 +Ref: Wc Program-Footnote-1724081 +Node: Miscellaneous Programs724175 +Node: Dupword Program725388 +Node: Alarm Program727419 +Node: Translate Program732224 +Ref: Translate Program-Footnote-1736787 +Node: Labels Program737057 +Ref: Labels Program-Footnote-1740408 +Node: Word Sorting740492 +Node: History Sorting744562 +Node: Extract Program746397 +Node: Simple Sed753921 +Node: Igawk Program756991 +Ref: Igawk Program-Footnote-1771317 +Ref: Igawk Program-Footnote-2771518 +Ref: Igawk Program-Footnote-3771640 +Node: Anagram Program771755 +Node: Signature Program774816 +Node: Programs Summary776063 +Node: Programs Exercises777284 +Ref: Programs Exercises-Footnote-1781415 +Node: Advanced Features781506 +Node: Nondecimal Data783488 +Node: Array Sorting785078 +Node: Controlling Array Traversal785778 +Ref: Controlling Array Traversal-Footnote-1794144 +Node: Array Sorting Functions794262 +Ref: Array Sorting Functions-Footnote-1798148 +Node: Two-way I/O798344 +Ref: Two-way I/O-Footnote-1803289 +Ref: Two-way I/O-Footnote-2803475 +Node: TCP/IP Networking803557 +Node: Profiling806429 +Node: Advanced Features Summary814700 +Node: Internationalization816633 +Node: I18N and L10N818113 +Node: Explaining gettext818799 +Ref: Explaining gettext-Footnote-1823824 +Ref: Explaining gettext-Footnote-2824008 +Node: Programmer i18n824173 +Ref: Programmer i18n-Footnote-1829049 +Node: Translator i18n829098 +Node: String Extraction829892 +Ref: String Extraction-Footnote-1831023 +Node: Printf Ordering831109 +Ref: Printf Ordering-Footnote-1833895 +Node: I18N Portability833959 +Ref: I18N Portability-Footnote-1836415 +Node: I18N Example836478 +Ref: I18N Example-Footnote-1839281 +Node: Gawk I18N839353 +Node: I18N Summary839997 +Node: Debugger841337 +Node: Debugging842359 +Node: Debugging Concepts842800 +Node: Debugging Terms844610 +Node: Awk Debugging847182 +Node: Sample Debugging Session848088 +Node: Debugger Invocation848622 +Node: Finding The Bug850007 +Node: List of Debugger Commands856486 +Node: Breakpoint Control857818 +Node: Debugger Execution Control861495 +Node: Viewing And Changing Data864854 +Node: Execution Stack868230 +Node: Debugger Info869865 +Node: Miscellaneous Debugger Commands873910 +Node: Readline Support878911 +Node: Limitations879805 +Node: Debugging Summary881920 +Node: Arbitrary Precision Arithmetic883094 +Node: Computer Arithmetic884510 +Ref: table-numeric-ranges888087 +Ref: Computer Arithmetic-Footnote-1888611 +Node: Math Definitions888668 +Ref: table-ieee-formats891963 +Ref: Math Definitions-Footnote-1892567 +Node: MPFR features892672 +Node: FP Math Caution894343 +Ref: FP Math Caution-Footnote-1895393 +Node: Inexactness of computations895762 +Node: Inexact representation896721 +Node: Comparing FP Values898079 +Node: Errors accumulate899161 +Node: Getting Accuracy900593 +Node: Try To Round903297 +Node: Setting precision904196 +Ref: table-predefined-precision-strings904880 +Node: Setting the rounding mode906709 +Ref: table-gawk-rounding-modes907073 +Ref: Setting the rounding mode-Footnote-1910525 +Node: Arbitrary Precision Integers910704 +Ref: Arbitrary Precision Integers-Footnote-1915602 +Node: POSIX Floating Point Problems915751 +Ref: POSIX Floating Point Problems-Footnote-1919630 +Node: Floating point summary919668 +Node: Dynamic Extensions921855 +Node: Extension Intro923407 +Node: Plugin License924672 +Node: Extension Mechanism Outline925469 +Ref: figure-load-extension925897 +Ref: figure-register-new-function927377 +Ref: figure-call-new-function928381 +Node: Extension API Description930368 +Node: Extension API Functions Introduction931902 +Node: General Data Types936771 +Ref: General Data Types-Footnote-1942671 +Node: Memory Allocation Functions942970 +Ref: Memory Allocation Functions-Footnote-1945809 +Node: Constructor Functions945908 +Node: Registration Functions947647 +Node: Extension Functions948332 +Node: Exit Callback Functions950629 +Node: Extension Version String951877 +Node: Input Parsers952540 +Node: Output Wrappers962415 +Node: Two-way processors966928 +Node: Printing Messages969191 +Ref: Printing Messages-Footnote-1970267 +Node: Updating `ERRNO'970419 +Node: Requesting Values971159 +Ref: table-value-types-returned971886 +Node: Accessing Parameters972843 +Node: Symbol Table Access974077 +Node: Symbol table by name974591 +Node: Symbol table by cookie976611 +Ref: Symbol table by cookie-Footnote-1980756 +Node: Cached values980819 +Ref: Cached values-Footnote-1984315 +Node: Array Manipulation984406 +Ref: Array Manipulation-Footnote-1985496 +Node: Array Data Types985533 +Ref: Array Data Types-Footnote-1988188 +Node: Array Functions988280 +Node: Flattening Arrays992139 +Node: Creating Arrays999041 +Node: Redirection API1003812 +Node: Extension API Variables1006637 +Node: Extension Versioning1007270 +Node: Extension API Informational Variables1009161 +Node: Extension API Boilerplate1010226 +Node: Finding Extensions1014035 +Node: Extension Example1014595 +Node: Internal File Description1015367 +Node: Internal File Ops1019434 +Ref: Internal File Ops-Footnote-11031185 +Node: Using Internal File Ops1031325 +Ref: Using Internal File Ops-Footnote-11033708 +Node: Extension Samples1033981 +Node: Extension Sample File Functions1035509 +Node: Extension Sample Fnmatch1043190 +Node: Extension Sample Fork1044678 +Node: Extension Sample Inplace1045893 +Node: Extension Sample Ord1047979 +Node: Extension Sample Readdir1048815 +Ref: table-readdir-file-types1049692 +Node: Extension Sample Revout1050503 +Node: Extension Sample Rev2way1051092 +Node: Extension Sample Read write array1051832 +Node: Extension Sample Readfile1053772 +Node: Extension Sample Time1054867 +Node: Extension Sample API Tests1056215 +Node: gawkextlib1056706 +Node: Extension summary1059407 +Node: Extension Exercises1063096 +Node: Language History1064592 +Node: V7/SVR3.11066248 +Node: SVR41068401 +Node: POSIX1069835 +Node: BTL1071216 +Node: POSIX/GNU1071947 +Node: Feature History1077783 +Node: Common Extensions1091577 +Node: Ranges and Locales1092949 +Ref: Ranges and Locales-Footnote-11097568 +Ref: Ranges and Locales-Footnote-21097595 +Ref: Ranges and Locales-Footnote-31097830 +Node: Contributors1098051 +Node: History summary1103591 +Node: Installation1104970 +Node: Gawk Distribution1105916 +Node: Getting1106400 +Node: Extracting1107223 +Node: Distribution contents1108860 +Node: Unix Installation1114962 +Node: Quick Installation1115645 +Node: Shell Startup Files1118056 +Node: Additional Configuration Options1119135 +Node: Configuration Philosophy1120939 +Node: Non-Unix Installation1123308 +Node: PC Installation1123766 +Node: PC Binary Installation1125086 +Node: PC Compiling1126934 +Ref: PC Compiling-Footnote-11129955 +Node: PC Testing1130064 +Node: PC Using1131240 +Node: Cygwin1135355 +Node: MSYS1136125 +Node: VMS Installation1136626 +Node: VMS Compilation1137418 +Ref: VMS Compilation-Footnote-11138647 +Node: VMS Dynamic Extensions1138705 +Node: VMS Installation Details1140389 +Node: VMS Running1142640 +Node: VMS GNV1145480 +Node: VMS Old Gawk1146215 +Node: Bugs1146685 +Node: Other Versions1150574 +Node: Installation summary1157008 +Node: Notes1158067 +Node: Compatibility Mode1158932 +Node: Additions1159714 +Node: Accessing The Source1160639 +Node: Adding Code1162074 +Node: New Ports1168231 +Node: Derived Files1172713 +Ref: Derived Files-Footnote-11178188 +Ref: Derived Files-Footnote-21178222 +Ref: Derived Files-Footnote-31178818 +Node: Future Extensions1178932 +Node: Implementation Limitations1179538 +Node: Extension Design1180786 +Node: Old Extension Problems1181940 +Ref: Old Extension Problems-Footnote-11183457 +Node: Extension New Mechanism Goals1183514 +Ref: Extension New Mechanism Goals-Footnote-11186874 +Node: Extension Other Design Decisions1187063 +Node: Extension Future Growth1189171 +Node: Old Extension Mechanism1190007 +Node: Notes summary1191769 +Node: Basic Concepts1192955 +Node: Basic High Level1193636 +Ref: figure-general-flow1193908 +Ref: figure-process-flow1194507 +Ref: Basic High Level-Footnote-11197736 +Node: Basic Data Typing1197921 +Node: Glossary1201249 +Node: Copying1233178 +Node: GNU Free Documentation License1270734 +Node: Index1295870  End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index e9d987f0..e0b44fa1 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -8807,6 +8807,7 @@ PROCINFO["@var{input_name}", "RETRY"] = 1 @end example When this element exists, @command{gawk} checks the value of the system +(C language) @code{errno} variable when an I/O error occurs. If @code{errno} indicates a subsequent I/O attempt may succeed, @code{getline} instead returns @minus{}2 and @@ -35284,6 +35285,11 @@ As of this writing, there are seven extensions: @item GD graphics library extension +@item +MPFR library extension +(this provides access to a number of MPFR functions that @command{gawk}'s +native MPFR support does not) + @item PDF extension @@ -35291,12 +35297,10 @@ PDF extension PostgreSQL extension @item -MPFR library extension -(this provides access to a number of MPFR functions that @command{gawk}'s -native MPFR support does not) +Redis extension @item -Redis extension +Select extension @item XML parser extension, using the @uref{http://expat.sourceforge.net, Expat} diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 178444a4..f8642fca 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -8407,6 +8407,7 @@ PROCINFO["@var{input_name}", "RETRY"] = 1 @end example When this element exists, @command{gawk} checks the value of the system +(C language) @code{errno} variable when an I/O error occurs. If @code{errno} indicates a subsequent I/O attempt may succeed, @code{getline} instead returns @minus{}2 and @@ -34375,6 +34376,11 @@ As of this writing, there are seven extensions: @item GD graphics library extension +@item +MPFR library extension +(this provides access to a number of MPFR functions that @command{gawk}'s +native MPFR support does not) + @item PDF extension @@ -34382,12 +34388,10 @@ PDF extension PostgreSQL extension @item -MPFR library extension -(this provides access to a number of MPFR functions that @command{gawk}'s -native MPFR support does not) +Redis extension @item -Redis extension +Select extension @item XML parser extension, using the @uref{http://expat.sourceforge.net, Expat} -- cgit v1.2.1 From a47af3141cf4a6b43e20db872e2b45ff9abb071f Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 31 Mar 2015 22:07:53 +0300 Subject: Get indirect calls working! --- ChangeLog | 9 ++++ awk.h | 4 +- builtin.c | 68 ++++++++++++++++++++++++++- indirectbuitin.awk | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++--- interpret.h | 6 ++- node.c | 9 ---- 6 files changed, 207 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 47ef45ee..4b7766d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2015-03-31 Arnold D. Robbins + + * awk.h (call_sub): Renamed from call_sub_func. + (call_match, call_split_func): Declare. + * builtin.c (call_sub): Renamed from call_sub_func. + (call_match, call_split_func): New functions. + * interpret.h (r_interpret): Call new functions as appropriate. + * node.c (r_unref): Revert change to handle Node_regex, not needed. + 2015-03-31 Arnold D. Robbins * awk.h (r_get_field): Declare. diff --git a/awk.h b/awk.h index 1205401b..4ac32e4a 100644 --- a/awk.h +++ b/awk.h @@ -1361,7 +1361,9 @@ extern NODE *do_rand(int nargs); extern NODE *do_srand(int nargs); extern NODE *do_match(int nargs); extern NODE *do_sub(int nargs, unsigned int flags); -extern NODE *call_sub_func(const char *name, int nargs); +extern NODE *call_sub(const char *name, int nargs); +extern NODE *call_match(int nargs); +extern NODE *call_split_func(const char *name, int nargs); extern NODE *format_tree(const char *, size_t, NODE **, long); extern NODE *do_lshift(int nargs); extern NODE *do_rshift(int nargs); diff --git a/builtin.c b/builtin.c index c222ce78..dde3121c 100644 --- a/builtin.c +++ b/builtin.c @@ -2994,10 +2994,10 @@ done: return make_number((AWKNUM) matches); } -/* call_sub_func --- call do_sub indirectly */ +/* call_sub --- call do_sub indirectly */ NODE * -call_sub_func(const char *name, int nargs) +call_sub(const char *name, int nargs) { unsigned int flags = 0; NODE *regex, *replace, *glob_flag; @@ -3070,6 +3070,70 @@ call_sub_func(const char *name, int nargs) return result; } +/* call_match --- call do_match indirectly */ + +NODE * +call_match(int nargs) +{ + NODE *regex, *text, *array; + NODE *result; + + regex = text = array = NULL; + if (nargs == 3) + array = POP(); + regex = POP(); + + /* Don't need to pop the string just to push it back ... */ + + regex = make_regnode(Node_regex, regex); + PUSH(regex); + + if (array) + PUSH(array); + + result = do_match(nargs); + return result; +} + +/* call_split_func --- call do_split or do_pat_split indirectly */ + +NODE * +call_split_func(const char *name, int nargs) +{ + NODE *regex, *seps; + NODE *result; + + regex = seps = NULL; + if (nargs < 2) + fatal(_("indirect call to %s requires at least two arguments"), + name); + + if (nargs == 4) + seps = POP(); + + if (nargs >= 3) { + regex = POP_STRING(); + regex = make_regnode(Node_regex, regex); + } else { + if (name[0] == 's') { + regex = make_regnode(Node_regex, FS_node->var_value); + regex->re_flags |= FS_DFLT; + } else + regex = make_regnode(Node_regex, FPAT_node->var_value); + nargs++; + } + + /* Don't need to pop the string or the data array */ + + PUSH(regex); + + if (seps) + PUSH(seps); + + result = (name[0] == 's') ? do_split(nargs) : do_patsplit(nargs); + + return result; +} /* make_integer - Convert an integer to a number node. */ diff --git a/indirectbuitin.awk b/indirectbuitin.awk index de3d5ccd..4d5291d2 100644 --- a/indirectbuitin.awk +++ b/indirectbuitin.awk @@ -2,9 +2,11 @@ function print_result(category, fname, builtin_result, indirect_result) { if (builtin_result == indirect_result) printf("%s: %s: pass\n", category, fname) - else + else { printf("%s: %s: fail: builtin: %s \tindirect: %s\n", category, fname, builtin_result, indirect_result) + exit 1 + } } @@ -189,14 +191,129 @@ BEGIN { # regexp functions -# fun = "match" -# print_result("regexp", fun, b1, i1) + fun = "match" + b1 = match("o+", "fooob") + rstart = RSTART + rlength = RLENGTH + i1 = @fun("o+", "fooob") + print_result("regexp", fun, b1, i1) + if (rstart != RSTART) { + printf("match: failure: biRSTART (%d) != iRSTART (%d)\n", + rstart, RSTART) + exit 1 + } + if (rlength != RLENGTH) { + printf("match: failure: biRLENGTH (%d) != iRLENGTH (%d)\n", + rlength, RLENGTH) + exit 1 + } -# fun = "patsplit" -# print_result("regexp", fun, b1, i1) + ############## start patsplit ############## + fun = "patsplit" + delete data + delete data2 + delete seps + delete seps2 + b1 = patsplit("a:b:c:d", data, ":", seps) + i1 = @fun("a:b:c:d", data2, ":", seps2) + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("patsplit1a: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + for (i in seps) { + if ((! (i in seps2)) || seps[i] != seps2[i]) { + printf("patsplit1b: fail: builtin seps[%d] (%s) != indirect seps[%d] (%s)\n", + i, seps[i], i, seps2[i]) + exit 1 + } + } + + fun = "patsplit" + delete data + delete data2 + b1 = patsplit("a:b:c:d", data, ":") + i1 = @fun("a:b:c:d", data2, ":") + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("patsplit2: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } -# fun = "split" -# print_result("regexp", fun, b1, i1) + fun = "patsplit" + delete data + delete data2 + FPAT = "[a-z]+" + b1 = patsplit("a b c d", data) + i1 = @fun("a b c d", data2) + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("patsplit3: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + ############## end patsplit ############## + + ############## start split ############## + fun = "split" + delete data + delete data2 + delete seps + delete seps2 + b1 = split("a:b:c:d", data, ":", seps) + i1 = @fun("a:b:c:d", data2, ":", seps2) + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("split1a: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + for (i in seps) { + if ((! (i in seps2)) || seps[i] != seps2[i]) { + printf("split1b: fail: builtin seps[%d] (%s) != indirect seps[%d] (%s)\n", + i, seps[i], i, seps2[i]) + exit 1 + } + } + + fun = "split" + delete data + delete data2 + b1 = split("a:b:c:d", data, ":") + i1 = @fun("a:b:c:d", data2, ":") + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("split2: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + + fun = "split" + delete data + delete data2 + b1 = split("a b c d", data) + i1 = @fun("a b c d", data2) + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("split3: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + ############## end split ############## # array functions diff --git a/interpret.h b/interpret.h index f9aa3115..6dce863a 100644 --- a/interpret.h +++ b/interpret.h @@ -1067,7 +1067,11 @@ match_re: /* call it */ if (the_func == (builtin_func_t) do_sub) - r = call_sub_func(t1->stptr, arg_count); + r = call_sub(t1->stptr, arg_count); + else if (the_func == do_match) + r = call_match(arg_count); + else if (the_func == do_split || the_func == do_patsplit) + r = call_split_func(t1->stptr, arg_count); else r = the_func(arg_count); diff --git a/node.c b/node.c index 7a1d99f6..9fd4c7b9 100644 --- a/node.c +++ b/node.c @@ -431,14 +431,6 @@ r_unref(NODE *tmp) #ifdef GAWKDEBUG if (tmp == NULL) return; - if (tmp->type == Node_regex) { -fprintf(stderr, "got here!\n"); fflush(stderr); - if (tmp->re_reg != NULL) - refree(tmp->re_reg); - if (tmp->re_text != NULL) - unref(tmp->re_text); - goto free_the_node; - } if ((tmp->flags & MALLOC) != 0) { if (tmp->valref > 1) { tmp->valref--; @@ -455,7 +447,6 @@ fprintf(stderr, "got here!\n"); fflush(stderr); mpfr_unset(tmp); free_wstr(tmp); -free_the_node: freenode(tmp); } -- cgit v1.2.1 From 67d5cc4c4034f16a2390e30d8e988713e5aedb68 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 31 Mar 2015 22:13:41 +0300 Subject: Add tests for indirect call of builtins. --- indirectbuitin.awk | 371 ----------------------------------------------- test/ChangeLog | 5 + test/Makefile.am | 4 +- test/Makefile.in | 9 +- test/Maketests | 5 + test/indirectbuiltin.awk | 371 +++++++++++++++++++++++++++++++++++++++++++++++ test/indirectbuiltin.ok | 43 ++++++ 7 files changed, 435 insertions(+), 373 deletions(-) delete mode 100644 indirectbuitin.awk create mode 100644 test/indirectbuiltin.awk create mode 100644 test/indirectbuiltin.ok diff --git a/indirectbuitin.awk b/indirectbuitin.awk deleted file mode 100644 index 4d5291d2..00000000 --- a/indirectbuitin.awk +++ /dev/null @@ -1,371 +0,0 @@ -function print_result(category, fname, builtin_result, indirect_result) -{ - if (builtin_result == indirect_result) - printf("%s: %s: pass\n", category, fname) - else { - printf("%s: %s: fail: builtin: %s \tindirect: %s\n", category, fname, - builtin_result, indirect_result) - exit 1 - } -} - - -BEGIN { -# math functions - - fun = "and" - b1 = and(0x11, 0x01) - i1 = @fun(0x11, 0x01) - print_result("math", fun, b1, i1) - - fun = "atan2" - b1 = atan2(-1, 0) - i1 = @fun(-1, 0) - print_result("math", fun, b1, i1) - - fun = "compl" - b1 = compl(0x1111) - i1 = @fun(0x1111) - print_result("math", fun, b1, i1) - - fun = "cos" - b1 = cos(3.1415927 / 4) - i1 = @fun(3.1415927 / 4) - print_result("math", fun, b1, i1) - - fun = "exp" - b1 = exp(2) - i1 = @fun(2) - print_result("math", fun, b1, i1) - - fun = "int" - b1 = int(3.1415927) - i1 = @fun(3.1415927) - print_result("math", fun, b1, i1) - - fun = "log" - b1 = log(10) - i1 = @fun(10) - print_result("math", fun, b1, i1) - - fun = "lshift" - b1 = lshift(1, 2) - i1 = @fun(1, 2) - print_result("math", fun, b1, i1) - - fun = "or" - b1 = or(0x10, 0x01) - i1 = @fun(0x10, 0x01) - print_result("math", fun, b1, i1) - - fun = "rand" - srand(1) - b1 = rand(); - srand(1) - i1 = @fun() - print_result("math", fun, b1, i1) - - fun = "rshift" - b1 = rshift(0x10, 1) - i1 = @fun(0x10, 1) - print_result("math", fun, b1, i1) - - fun = "sin" - b1 = sin(3.1415927 / 4) - i1 = @fun(3.1415927 / 4) - print_result("math", fun, b1, i1) - - fun = "sqrt" - b1 = sqrt(2) - i1 = @fun(2) - print_result("math", fun, b1, i1) - - srand() - fun = "srand" - b1 = srand() - i1 = @fun() - print_result("math", fun, b1, i1) - - fun = "xor" - b1 = xor(0x11, 0x01) - i1 = @fun(0x11, 0x01) - print_result("math", fun, b1, i1) - -# string functions - - fun = "gensub" - b1 = gensub("f", "q", "g", "ff11bb") - i1 = @fun("f", "q", "g", "ff11bb") - print_result("string", fun, b1, i1) - - fun = "gsub" - $0 = "ff11bb" - b1 = gsub("f", "q") - b2 = $0 - $0 = "ff11bb" - i1 = @fun("f", "q") - i2 = $0 - print_result("string", fun, b1, i1) - if (b2 != i2) { - printf("string: %s: fail: $0 (%s) != $0 (%s)\n", - fun, b2, i2) - exit 1 - } - - fun = "index" - b1 = index("hi, how are you", "how") - i1 = @fun("hi, how are you", "how") - print_result("string", fun, b1, i1) - - fun = "dcgettext" - b1 = dcgettext("hello, world") - i1 = @fun("hello, world") - print_result("string", fun, b1, i1) - - fun = "dcngettext" - b1 = dcngettext("hello, world", "howdy", 2) - i1 = @fun("hello, world", "howdy", 2) - print_result("string", fun, b1, i1) - - fun = "length" - b1 = length("hi, how are you") - i1 = @fun("hi, how are you") - print_result("string", fun, b1, i1) - - fun = "sprintf" - b1 = sprintf("%s world", "hello") - i1 = @fun("%s world", "hello") - print_result("string", fun, b1, i1) - - fun = "strtonum" - b1 = strtonum("0xdeadbeef") - i1 = @fun("0xdeadbeef") - print_result("string", fun, b1, i1) - - fun = "sub" - $0 = "ff11bb" - b1 = sub("f", "q") - b2 = $0 - $0 = "ff11bb" - i1 = @fun("f", "q") - i2 = $0 - print_result("string", fun, b1, i1) - if (b2 != i2) { - printf("string: %s: fail: $0 (%s) != $0 (%s)\n", - fun, b2, i2) - exit 1 - } - - fun = "substr" - b1 = substr("0xdeadbeef", 7, 4) - i1 = @fun("0xdeadbeef", 7, 4) - print_result("string", fun, b1, i1) - - fun = "tolower" - b1 = tolower("0xDeAdBeEf") - i1 = @fun("0xDeAdBeEf") - print_result("string", fun, b1, i1) - - fun = "toupper" - b1 = toupper("0xDeAdBeEf") - i1 = @fun("0xDeAdBeEf") - print_result("string", fun, b1, i1) - -# time functions - - fun = "mktime" - b1 = mktime("1990 02 11 12 00 00") - i1 = @fun("1990 02 11 12 00 00") - print_result("time", fun, b1, i1) - - then = b1 - fun = "strftime" - b1 = strftime(PROCINFO["strftime"], then) - i1 = @fun(PROCINFO["strftime"], then) - print_result("time", fun, b1, i1) - - fun = "systime" - b1 = systime() - i1 = @fun() - print_result("time", fun, b1, i1) - -# regexp functions - - fun = "match" - b1 = match("o+", "fooob") - rstart = RSTART - rlength = RLENGTH - i1 = @fun("o+", "fooob") - print_result("regexp", fun, b1, i1) - if (rstart != RSTART) { - printf("match: failure: biRSTART (%d) != iRSTART (%d)\n", - rstart, RSTART) - exit 1 - } - if (rlength != RLENGTH) { - printf("match: failure: biRLENGTH (%d) != iRLENGTH (%d)\n", - rlength, RLENGTH) - exit 1 - } - - ############## start patsplit ############## - fun = "patsplit" - delete data - delete data2 - delete seps - delete seps2 - b1 = patsplit("a:b:c:d", data, ":", seps) - i1 = @fun("a:b:c:d", data2, ":", seps2) - print_result("regexp", fun, b1, i1) - for (i in data) { - if ((! (i in data2)) || data[i] != data2[i]) { - printf("patsplit1a: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", - i, data[i], i, data2[i]) - exit 1 - } - } - for (i in seps) { - if ((! (i in seps2)) || seps[i] != seps2[i]) { - printf("patsplit1b: fail: builtin seps[%d] (%s) != indirect seps[%d] (%s)\n", - i, seps[i], i, seps2[i]) - exit 1 - } - } - - fun = "patsplit" - delete data - delete data2 - b1 = patsplit("a:b:c:d", data, ":") - i1 = @fun("a:b:c:d", data2, ":") - print_result("regexp", fun, b1, i1) - for (i in data) { - if ((! (i in data2)) || data[i] != data2[i]) { - printf("patsplit2: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", - i, data[i], i, data2[i]) - exit 1 - } - } - - fun = "patsplit" - delete data - delete data2 - FPAT = "[a-z]+" - b1 = patsplit("a b c d", data) - i1 = @fun("a b c d", data2) - print_result("regexp", fun, b1, i1) - for (i in data) { - if ((! (i in data2)) || data[i] != data2[i]) { - printf("patsplit3: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", - i, data[i], i, data2[i]) - exit 1 - } - } - ############## end patsplit ############## - - ############## start split ############## - fun = "split" - delete data - delete data2 - delete seps - delete seps2 - b1 = split("a:b:c:d", data, ":", seps) - i1 = @fun("a:b:c:d", data2, ":", seps2) - print_result("regexp", fun, b1, i1) - for (i in data) { - if ((! (i in data2)) || data[i] != data2[i]) { - printf("split1a: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", - i, data[i], i, data2[i]) - exit 1 - } - } - for (i in seps) { - if ((! (i in seps2)) || seps[i] != seps2[i]) { - printf("split1b: fail: builtin seps[%d] (%s) != indirect seps[%d] (%s)\n", - i, seps[i], i, seps2[i]) - exit 1 - } - } - - fun = "split" - delete data - delete data2 - b1 = split("a:b:c:d", data, ":") - i1 = @fun("a:b:c:d", data2, ":") - print_result("regexp", fun, b1, i1) - for (i in data) { - if ((! (i in data2)) || data[i] != data2[i]) { - printf("split2: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", - i, data[i], i, data2[i]) - exit 1 - } - } - - fun = "split" - delete data - delete data2 - b1 = split("a b c d", data) - i1 = @fun("a b c d", data2) - print_result("regexp", fun, b1, i1) - for (i in data) { - if ((! (i in data2)) || data[i] != data2[i]) { - printf("split3: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", - i, data[i], i, data2[i]) - exit 1 - } - } - ############## end split ############## - -# array functions - - split("z y x w v u t", data) - fun = "asort" - asort(data, newdata) - @fun(data, newdata2) - print_result("array", fun, b1, i1) - for (i in newdata) { - if (! (i in newdata2) || newdata[i] != newdata2[i]) { - print fun ": failed, index", i - exit - } - } - - for (i in data) - data2[data[i]] = i - - fun = "asorti" - asorti(data2, newdata) - @fun(data2, newdata2) - print_result("array", fun, b1, i1) - for (i in newdata) { - if (! (i in newdata2) || newdata[i] != newdata2[i]) { - print fun ": failed, index", i, "value", newdata[i], newdata2[i] - exit - } - } - - arr[1] = arr[2] = 42 - fun = "isarray" - b1 = isarray(arr) - i1 = @fun(arr) - print_result("array", fun, b1, i1) - -# i/o functions - - print("hi") > "x1.out" - print("hi") > "x2.out" - - fun = "fflush" - b1 = fflush("x1.out") - i1 = @fun("x2.out") - print_result("i/o", fun, b1, i1) - - fun = "close" - b1 = close("x1.out") - i1 = @fun("x2.out") - print_result("i/o", fun, b1, i1) - - fun = "system" - b1 = system("rm x1.out") - i1 = @fun("rm x2.out") - print_result("i/o", fun, b1, i1) -} diff --git a/test/ChangeLog b/test/ChangeLog index ab7a2163..38ae4d3a 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2015-03-31 Arnold D. Robbins + + * Makefile.am (indirectbuiltin): New test. + * indirectbuiltin.awk, indirectbuiltin.ok: New files. + 2015-03-24 Arnold D. Robbins * id.ok: Update after fixes in code. diff --git a/test/Makefile.am b/test/Makefile.am index f1a0a275..ec15fcd9 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -429,6 +429,8 @@ EXTRA_DIST = \ include.awk \ include.ok \ include2.ok \ + indirectbuiltin.awk \ + indirectbuiltin.ok \ indirectcall.awk \ indirectcall.in \ indirectcall.ok \ @@ -1043,7 +1045,7 @@ GAWK_EXT_TESTS = \ genpot gensub gensub2 getlndir gnuops2 gnuops3 gnureops \ icasefs icasers id igncdym igncfs ignrcas2 ignrcase \ incdupe incdupe2 incdupe3 incdupe4 incdupe5 incdupe6 incdupe7 \ - include include2 indirectcall indirectcall2 \ + include include2 indirectbuiltin indirectcall indirectcall2 \ lint lintold lintwarn \ manyfiles match1 match2 match3 mbstr1 \ nastyparm next nondec nondec2 \ diff --git a/test/Makefile.in b/test/Makefile.in index b794e04e..e2656588 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -686,6 +686,8 @@ EXTRA_DIST = \ include.awk \ include.ok \ include2.ok \ + indirectbuiltin.awk \ + indirectbuiltin.ok \ indirectcall.awk \ indirectcall.in \ indirectcall.ok \ @@ -1299,7 +1301,7 @@ GAWK_EXT_TESTS = \ genpot gensub gensub2 getlndir gnuops2 gnuops3 gnureops \ icasefs icasers id igncdym igncfs ignrcas2 ignrcase \ incdupe incdupe2 incdupe3 incdupe4 incdupe5 incdupe6 incdupe7 \ - include include2 indirectcall indirectcall2 \ + include include2 indirectbuiltin indirectcall indirectcall2 \ lint lintold lintwarn \ manyfiles match1 match2 match3 mbstr1 \ nastyparm next nondec nondec2 \ @@ -3586,6 +3588,11 @@ include: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +indirectbuiltin: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + indirectcall: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index 8c270869..f36e495e 100644 --- a/test/Maketests +++ b/test/Maketests @@ -1107,6 +1107,11 @@ include: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +indirectbuiltin: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + indirectcall: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/indirectbuiltin.awk b/test/indirectbuiltin.awk new file mode 100644 index 00000000..4d5291d2 --- /dev/null +++ b/test/indirectbuiltin.awk @@ -0,0 +1,371 @@ +function print_result(category, fname, builtin_result, indirect_result) +{ + if (builtin_result == indirect_result) + printf("%s: %s: pass\n", category, fname) + else { + printf("%s: %s: fail: builtin: %s \tindirect: %s\n", category, fname, + builtin_result, indirect_result) + exit 1 + } +} + + +BEGIN { +# math functions + + fun = "and" + b1 = and(0x11, 0x01) + i1 = @fun(0x11, 0x01) + print_result("math", fun, b1, i1) + + fun = "atan2" + b1 = atan2(-1, 0) + i1 = @fun(-1, 0) + print_result("math", fun, b1, i1) + + fun = "compl" + b1 = compl(0x1111) + i1 = @fun(0x1111) + print_result("math", fun, b1, i1) + + fun = "cos" + b1 = cos(3.1415927 / 4) + i1 = @fun(3.1415927 / 4) + print_result("math", fun, b1, i1) + + fun = "exp" + b1 = exp(2) + i1 = @fun(2) + print_result("math", fun, b1, i1) + + fun = "int" + b1 = int(3.1415927) + i1 = @fun(3.1415927) + print_result("math", fun, b1, i1) + + fun = "log" + b1 = log(10) + i1 = @fun(10) + print_result("math", fun, b1, i1) + + fun = "lshift" + b1 = lshift(1, 2) + i1 = @fun(1, 2) + print_result("math", fun, b1, i1) + + fun = "or" + b1 = or(0x10, 0x01) + i1 = @fun(0x10, 0x01) + print_result("math", fun, b1, i1) + + fun = "rand" + srand(1) + b1 = rand(); + srand(1) + i1 = @fun() + print_result("math", fun, b1, i1) + + fun = "rshift" + b1 = rshift(0x10, 1) + i1 = @fun(0x10, 1) + print_result("math", fun, b1, i1) + + fun = "sin" + b1 = sin(3.1415927 / 4) + i1 = @fun(3.1415927 / 4) + print_result("math", fun, b1, i1) + + fun = "sqrt" + b1 = sqrt(2) + i1 = @fun(2) + print_result("math", fun, b1, i1) + + srand() + fun = "srand" + b1 = srand() + i1 = @fun() + print_result("math", fun, b1, i1) + + fun = "xor" + b1 = xor(0x11, 0x01) + i1 = @fun(0x11, 0x01) + print_result("math", fun, b1, i1) + +# string functions + + fun = "gensub" + b1 = gensub("f", "q", "g", "ff11bb") + i1 = @fun("f", "q", "g", "ff11bb") + print_result("string", fun, b1, i1) + + fun = "gsub" + $0 = "ff11bb" + b1 = gsub("f", "q") + b2 = $0 + $0 = "ff11bb" + i1 = @fun("f", "q") + i2 = $0 + print_result("string", fun, b1, i1) + if (b2 != i2) { + printf("string: %s: fail: $0 (%s) != $0 (%s)\n", + fun, b2, i2) + exit 1 + } + + fun = "index" + b1 = index("hi, how are you", "how") + i1 = @fun("hi, how are you", "how") + print_result("string", fun, b1, i1) + + fun = "dcgettext" + b1 = dcgettext("hello, world") + i1 = @fun("hello, world") + print_result("string", fun, b1, i1) + + fun = "dcngettext" + b1 = dcngettext("hello, world", "howdy", 2) + i1 = @fun("hello, world", "howdy", 2) + print_result("string", fun, b1, i1) + + fun = "length" + b1 = length("hi, how are you") + i1 = @fun("hi, how are you") + print_result("string", fun, b1, i1) + + fun = "sprintf" + b1 = sprintf("%s world", "hello") + i1 = @fun("%s world", "hello") + print_result("string", fun, b1, i1) + + fun = "strtonum" + b1 = strtonum("0xdeadbeef") + i1 = @fun("0xdeadbeef") + print_result("string", fun, b1, i1) + + fun = "sub" + $0 = "ff11bb" + b1 = sub("f", "q") + b2 = $0 + $0 = "ff11bb" + i1 = @fun("f", "q") + i2 = $0 + print_result("string", fun, b1, i1) + if (b2 != i2) { + printf("string: %s: fail: $0 (%s) != $0 (%s)\n", + fun, b2, i2) + exit 1 + } + + fun = "substr" + b1 = substr("0xdeadbeef", 7, 4) + i1 = @fun("0xdeadbeef", 7, 4) + print_result("string", fun, b1, i1) + + fun = "tolower" + b1 = tolower("0xDeAdBeEf") + i1 = @fun("0xDeAdBeEf") + print_result("string", fun, b1, i1) + + fun = "toupper" + b1 = toupper("0xDeAdBeEf") + i1 = @fun("0xDeAdBeEf") + print_result("string", fun, b1, i1) + +# time functions + + fun = "mktime" + b1 = mktime("1990 02 11 12 00 00") + i1 = @fun("1990 02 11 12 00 00") + print_result("time", fun, b1, i1) + + then = b1 + fun = "strftime" + b1 = strftime(PROCINFO["strftime"], then) + i1 = @fun(PROCINFO["strftime"], then) + print_result("time", fun, b1, i1) + + fun = "systime" + b1 = systime() + i1 = @fun() + print_result("time", fun, b1, i1) + +# regexp functions + + fun = "match" + b1 = match("o+", "fooob") + rstart = RSTART + rlength = RLENGTH + i1 = @fun("o+", "fooob") + print_result("regexp", fun, b1, i1) + if (rstart != RSTART) { + printf("match: failure: biRSTART (%d) != iRSTART (%d)\n", + rstart, RSTART) + exit 1 + } + if (rlength != RLENGTH) { + printf("match: failure: biRLENGTH (%d) != iRLENGTH (%d)\n", + rlength, RLENGTH) + exit 1 + } + + ############## start patsplit ############## + fun = "patsplit" + delete data + delete data2 + delete seps + delete seps2 + b1 = patsplit("a:b:c:d", data, ":", seps) + i1 = @fun("a:b:c:d", data2, ":", seps2) + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("patsplit1a: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + for (i in seps) { + if ((! (i in seps2)) || seps[i] != seps2[i]) { + printf("patsplit1b: fail: builtin seps[%d] (%s) != indirect seps[%d] (%s)\n", + i, seps[i], i, seps2[i]) + exit 1 + } + } + + fun = "patsplit" + delete data + delete data2 + b1 = patsplit("a:b:c:d", data, ":") + i1 = @fun("a:b:c:d", data2, ":") + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("patsplit2: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + + fun = "patsplit" + delete data + delete data2 + FPAT = "[a-z]+" + b1 = patsplit("a b c d", data) + i1 = @fun("a b c d", data2) + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("patsplit3: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + ############## end patsplit ############## + + ############## start split ############## + fun = "split" + delete data + delete data2 + delete seps + delete seps2 + b1 = split("a:b:c:d", data, ":", seps) + i1 = @fun("a:b:c:d", data2, ":", seps2) + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("split1a: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + for (i in seps) { + if ((! (i in seps2)) || seps[i] != seps2[i]) { + printf("split1b: fail: builtin seps[%d] (%s) != indirect seps[%d] (%s)\n", + i, seps[i], i, seps2[i]) + exit 1 + } + } + + fun = "split" + delete data + delete data2 + b1 = split("a:b:c:d", data, ":") + i1 = @fun("a:b:c:d", data2, ":") + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("split2: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + + fun = "split" + delete data + delete data2 + b1 = split("a b c d", data) + i1 = @fun("a b c d", data2) + print_result("regexp", fun, b1, i1) + for (i in data) { + if ((! (i in data2)) || data[i] != data2[i]) { + printf("split3: fail: builtin data[%d] (%s) != indirect data[%d] (%s)\n", + i, data[i], i, data2[i]) + exit 1 + } + } + ############## end split ############## + +# array functions + + split("z y x w v u t", data) + fun = "asort" + asort(data, newdata) + @fun(data, newdata2) + print_result("array", fun, b1, i1) + for (i in newdata) { + if (! (i in newdata2) || newdata[i] != newdata2[i]) { + print fun ": failed, index", i + exit + } + } + + for (i in data) + data2[data[i]] = i + + fun = "asorti" + asorti(data2, newdata) + @fun(data2, newdata2) + print_result("array", fun, b1, i1) + for (i in newdata) { + if (! (i in newdata2) || newdata[i] != newdata2[i]) { + print fun ": failed, index", i, "value", newdata[i], newdata2[i] + exit + } + } + + arr[1] = arr[2] = 42 + fun = "isarray" + b1 = isarray(arr) + i1 = @fun(arr) + print_result("array", fun, b1, i1) + +# i/o functions + + print("hi") > "x1.out" + print("hi") > "x2.out" + + fun = "fflush" + b1 = fflush("x1.out") + i1 = @fun("x2.out") + print_result("i/o", fun, b1, i1) + + fun = "close" + b1 = close("x1.out") + i1 = @fun("x2.out") + print_result("i/o", fun, b1, i1) + + fun = "system" + b1 = system("rm x1.out") + i1 = @fun("rm x2.out") + print_result("i/o", fun, b1, i1) +} diff --git a/test/indirectbuiltin.ok b/test/indirectbuiltin.ok new file mode 100644 index 00000000..312bbd76 --- /dev/null +++ b/test/indirectbuiltin.ok @@ -0,0 +1,43 @@ +math: and: pass +math: atan2: pass +math: compl: pass +math: cos: pass +math: exp: pass +math: int: pass +math: log: pass +math: lshift: pass +math: or: pass +math: rand: pass +math: rshift: pass +math: sin: pass +math: sqrt: pass +math: srand: pass +math: xor: pass +string: gensub: pass +string: gsub: pass +string: index: pass +string: dcgettext: pass +string: dcngettext: pass +string: length: pass +string: sprintf: pass +string: strtonum: pass +string: sub: pass +string: substr: pass +string: tolower: pass +string: toupper: pass +time: mktime: pass +time: strftime: pass +time: systime: pass +regexp: match: pass +regexp: patsplit: pass +regexp: patsplit: pass +regexp: patsplit: pass +regexp: split: pass +regexp: split: pass +regexp: split: pass +array: asort: pass +array: asorti: pass +array: isarray: pass +i/o: fflush: pass +i/o: close: pass +i/o: system: pass -- cgit v1.2.1 From 0ed7e09458bdb6185586a8a0bec747b2f800ca16 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 31 Mar 2015 22:21:30 +0300 Subject: Update doc on calling built-ins indirectly. --- doc/ChangeLog | 5 + doc/gawk.info | 588 ++++++++++++++++++++++++++++---------------------------- doc/gawk.texi | 21 +- doc/gawktexi.in | 21 +- 4 files changed, 337 insertions(+), 298 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 6dbe79dc..2f5dabb0 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2015-03-31 Arnold D. Robbins + + * gawktexi.in: Update discussion of calling built-in functions + indirectly. + 2015-03-24 Arnold D. Robbins * gawktexi.in: Minor fixes from Antonio Colombo and new exercise diff --git a/doc/gawk.info b/doc/gawk.info index 6cb2abdb..9b6a46fc 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -14294,9 +14294,17 @@ function call. Starting with version 4.1.2 of `gawk', indirect function calls may also be used with built-in functions and with extension functions -(*note Dynamic Extensions::). The only thing you cannot do is pass a -regular expression constant to a built-in function through an indirect -function call.(1) +(*note Dynamic Extensions::). There are some limitations when calling +built-in functions indirectly, as follows. + + * You cannot pass a regular expression constant to a built-in + function through an indirect function call.(1) This applies to the + `sub()', `gsub()', `gensub()', `match()', `split()' and + `patsplit()' functions. + + * If calling `sub()' or `gsub()', you may only pass two arguments, + since those functions are unusual in that they update their third + argument. This means that `$0' will be updated. `gawk' does its best to make indirect function calls efficient. For example, in the following case: @@ -34777,292 +34785,292 @@ Node: Pass By Value/Reference579678 Node: Return Statement583175 Node: Dynamic Typing586154 Node: Indirect Calls587083 -Ref: Indirect Calls-Footnote-1596948 -Node: Functions Summary597076 -Node: Library Functions599778 -Ref: Library Functions-Footnote-1603386 -Ref: Library Functions-Footnote-2603529 -Node: Library Names603700 -Ref: Library Names-Footnote-1607158 -Ref: Library Names-Footnote-2607381 -Node: General Functions607467 -Node: Strtonum Function608570 -Node: Assert Function611592 -Node: Round Function614916 -Node: Cliff Random Function616457 -Node: Ordinal Functions617473 -Ref: Ordinal Functions-Footnote-1620536 -Ref: Ordinal Functions-Footnote-2620788 -Node: Join Function620999 -Ref: Join Function-Footnote-1622769 -Node: Getlocaltime Function622969 -Node: Readfile Function626713 -Node: Shell Quoting628685 -Node: Data File Management630086 -Node: Filetrans Function630718 -Node: Rewind Function634814 -Node: File Checking636200 -Ref: File Checking-Footnote-1637533 -Node: Empty Files637734 -Node: Ignoring Assigns639713 -Node: Getopt Function641263 -Ref: Getopt Function-Footnote-1652727 -Node: Passwd Functions652927 -Ref: Passwd Functions-Footnote-1661767 -Node: Group Functions661855 -Ref: Group Functions-Footnote-1669752 -Node: Walking Arrays669957 -Node: Library Functions Summary672963 -Node: Library Exercises674365 -Node: Sample Programs675645 -Node: Running Examples676415 -Node: Clones677143 -Node: Cut Program678367 -Node: Egrep Program688087 -Ref: Egrep Program-Footnote-1695590 -Node: Id Program695700 -Node: Split Program699376 -Ref: Split Program-Footnote-1702830 -Node: Tee Program702958 -Node: Uniq Program705747 -Node: Wc Program713166 -Ref: Wc Program-Footnote-1717416 -Node: Miscellaneous Programs717510 -Node: Dupword Program718723 -Node: Alarm Program720754 -Node: Translate Program725559 -Ref: Translate Program-Footnote-1730122 -Node: Labels Program730392 -Ref: Labels Program-Footnote-1733743 -Node: Word Sorting733827 -Node: History Sorting737897 -Node: Extract Program739732 -Node: Simple Sed747256 -Node: Igawk Program750326 -Ref: Igawk Program-Footnote-1764652 -Ref: Igawk Program-Footnote-2764853 -Ref: Igawk Program-Footnote-3764975 -Node: Anagram Program765090 -Node: Signature Program768151 -Node: Programs Summary769398 -Node: Programs Exercises770619 -Ref: Programs Exercises-Footnote-1774750 -Node: Advanced Features774841 -Node: Nondecimal Data776823 -Node: Array Sorting778413 -Node: Controlling Array Traversal779113 -Ref: Controlling Array Traversal-Footnote-1787479 -Node: Array Sorting Functions787597 -Ref: Array Sorting Functions-Footnote-1791483 -Node: Two-way I/O791679 -Ref: Two-way I/O-Footnote-1796624 -Ref: Two-way I/O-Footnote-2796810 -Node: TCP/IP Networking796892 -Node: Profiling799764 -Node: Advanced Features Summary807305 -Node: Internationalization809238 -Node: I18N and L10N810718 -Node: Explaining gettext811404 -Ref: Explaining gettext-Footnote-1816429 -Ref: Explaining gettext-Footnote-2816613 -Node: Programmer i18n816778 -Ref: Programmer i18n-Footnote-1821654 -Node: Translator i18n821703 -Node: String Extraction822497 -Ref: String Extraction-Footnote-1823628 -Node: Printf Ordering823714 -Ref: Printf Ordering-Footnote-1826500 -Node: I18N Portability826564 -Ref: I18N Portability-Footnote-1829020 -Node: I18N Example829083 -Ref: I18N Example-Footnote-1831886 -Node: Gawk I18N831958 -Node: I18N Summary832602 -Node: Debugger833942 -Node: Debugging834964 -Node: Debugging Concepts835405 -Node: Debugging Terms837215 -Node: Awk Debugging839787 -Node: Sample Debugging Session840693 -Node: Debugger Invocation841227 -Node: Finding The Bug842612 -Node: List of Debugger Commands849091 -Node: Breakpoint Control850423 -Node: Debugger Execution Control854100 -Node: Viewing And Changing Data857459 -Node: Execution Stack860835 -Node: Debugger Info862470 -Node: Miscellaneous Debugger Commands866515 -Node: Readline Support871516 -Node: Limitations872410 -Node: Debugging Summary874525 -Node: Arbitrary Precision Arithmetic875699 -Node: Computer Arithmetic877115 -Ref: table-numeric-ranges880692 -Ref: Computer Arithmetic-Footnote-1881216 -Node: Math Definitions881273 -Ref: table-ieee-formats884568 -Ref: Math Definitions-Footnote-1885172 -Node: MPFR features885277 -Node: FP Math Caution886948 -Ref: FP Math Caution-Footnote-1887998 -Node: Inexactness of computations888367 -Node: Inexact representation889326 -Node: Comparing FP Values890684 -Node: Errors accumulate891766 -Node: Getting Accuracy893198 -Node: Try To Round895902 -Node: Setting precision896801 -Ref: table-predefined-precision-strings897485 -Node: Setting the rounding mode899314 -Ref: table-gawk-rounding-modes899678 -Ref: Setting the rounding mode-Footnote-1903130 -Node: Arbitrary Precision Integers903309 -Ref: Arbitrary Precision Integers-Footnote-1906293 -Node: POSIX Floating Point Problems906442 -Ref: POSIX Floating Point Problems-Footnote-1910321 -Node: Floating point summary910359 -Node: Dynamic Extensions912546 -Node: Extension Intro914098 -Node: Plugin License915363 -Node: Extension Mechanism Outline916160 -Ref: figure-load-extension916588 -Ref: figure-register-new-function918068 -Ref: figure-call-new-function919072 -Node: Extension API Description921059 -Node: Extension API Functions Introduction922509 -Node: General Data Types927330 -Ref: General Data Types-Footnote-1933230 -Node: Memory Allocation Functions933529 -Ref: Memory Allocation Functions-Footnote-1936368 -Node: Constructor Functions936467 -Node: Registration Functions938206 -Node: Extension Functions938891 -Node: Exit Callback Functions941188 -Node: Extension Version String942436 -Node: Input Parsers943099 -Node: Output Wrappers952974 -Node: Two-way processors957487 -Node: Printing Messages959750 -Ref: Printing Messages-Footnote-1960826 -Node: Updating `ERRNO'960978 -Node: Requesting Values961718 -Ref: table-value-types-returned962445 -Node: Accessing Parameters963402 -Node: Symbol Table Access964636 -Node: Symbol table by name965150 -Node: Symbol table by cookie967170 -Ref: Symbol table by cookie-Footnote-1971315 -Node: Cached values971378 -Ref: Cached values-Footnote-1974874 -Node: Array Manipulation974965 -Ref: Array Manipulation-Footnote-1976063 -Node: Array Data Types976100 -Ref: Array Data Types-Footnote-1978755 -Node: Array Functions978847 -Node: Flattening Arrays982706 -Node: Creating Arrays989608 -Node: Extension API Variables994379 -Node: Extension Versioning995015 -Node: Extension API Informational Variables996906 -Node: Extension API Boilerplate997971 -Node: Finding Extensions1001780 -Node: Extension Example1002340 -Node: Internal File Description1003112 -Node: Internal File Ops1007179 -Ref: Internal File Ops-Footnote-11018930 -Node: Using Internal File Ops1019070 -Ref: Using Internal File Ops-Footnote-11021453 -Node: Extension Samples1021726 -Node: Extension Sample File Functions1023254 -Node: Extension Sample Fnmatch1030935 -Node: Extension Sample Fork1032423 -Node: Extension Sample Inplace1033638 -Node: Extension Sample Ord1035724 -Node: Extension Sample Readdir1036560 -Ref: table-readdir-file-types1037437 -Node: Extension Sample Revout1038248 -Node: Extension Sample Rev2way1038837 -Node: Extension Sample Read write array1039577 -Node: Extension Sample Readfile1041517 -Node: Extension Sample Time1042612 -Node: Extension Sample API Tests1043960 -Node: gawkextlib1044451 -Node: Extension summary1047129 -Node: Extension Exercises1050818 -Node: Language History1052314 -Node: V7/SVR3.11053970 -Node: SVR41056123 -Node: POSIX1057557 -Node: BTL1058938 -Node: POSIX/GNU1059669 -Node: Feature History1065190 -Node: Common Extensions1078288 -Node: Ranges and Locales1079660 -Ref: Ranges and Locales-Footnote-11084279 -Ref: Ranges and Locales-Footnote-21084306 -Ref: Ranges and Locales-Footnote-31084541 -Node: Contributors1084762 -Node: History summary1090302 -Node: Installation1091681 -Node: Gawk Distribution1092627 -Node: Getting1093111 -Node: Extracting1093934 -Node: Distribution contents1095571 -Node: Unix Installation1101325 -Node: Quick Installation1101942 -Node: Additional Configuration Options1104366 -Node: Configuration Philosophy1106169 -Node: Non-Unix Installation1108538 -Node: PC Installation1108996 -Node: PC Binary Installation1110316 -Node: PC Compiling1112164 -Ref: PC Compiling-Footnote-11115185 -Node: PC Testing1115294 -Node: PC Using1116470 -Node: Cygwin1120585 -Node: MSYS1121355 -Node: VMS Installation1121856 -Node: VMS Compilation1122648 -Ref: VMS Compilation-Footnote-11123877 -Node: VMS Dynamic Extensions1123935 -Node: VMS Installation Details1125619 -Node: VMS Running1127870 -Node: VMS GNV1130710 -Node: VMS Old Gawk1131445 -Node: Bugs1131915 -Node: Other Versions1135804 -Node: Installation summary1142238 -Node: Notes1143297 -Node: Compatibility Mode1144162 -Node: Additions1144944 -Node: Accessing The Source1145869 -Node: Adding Code1147304 -Node: New Ports1153461 -Node: Derived Files1157943 -Ref: Derived Files-Footnote-11163418 -Ref: Derived Files-Footnote-21163452 -Ref: Derived Files-Footnote-31164048 -Node: Future Extensions1164162 -Node: Implementation Limitations1164768 -Node: Extension Design1166016 -Node: Old Extension Problems1167170 -Ref: Old Extension Problems-Footnote-11168687 -Node: Extension New Mechanism Goals1168744 -Ref: Extension New Mechanism Goals-Footnote-11172104 -Node: Extension Other Design Decisions1172293 -Node: Extension Future Growth1174401 -Node: Old Extension Mechanism1175237 -Node: Notes summary1176999 -Node: Basic Concepts1178185 -Node: Basic High Level1178866 -Ref: figure-general-flow1179138 -Ref: figure-process-flow1179737 -Ref: Basic High Level-Footnote-11182966 -Node: Basic Data Typing1183151 -Node: Glossary1186479 -Node: Copying1218408 -Node: GNU Free Documentation License1255964 -Node: Index1281100 +Ref: Indirect Calls-Footnote-1597326 +Node: Functions Summary597454 +Node: Library Functions600156 +Ref: Library Functions-Footnote-1603764 +Ref: Library Functions-Footnote-2603907 +Node: Library Names604078 +Ref: Library Names-Footnote-1607536 +Ref: Library Names-Footnote-2607759 +Node: General Functions607845 +Node: Strtonum Function608948 +Node: Assert Function611970 +Node: Round Function615294 +Node: Cliff Random Function616835 +Node: Ordinal Functions617851 +Ref: Ordinal Functions-Footnote-1620914 +Ref: Ordinal Functions-Footnote-2621166 +Node: Join Function621377 +Ref: Join Function-Footnote-1623147 +Node: Getlocaltime Function623347 +Node: Readfile Function627091 +Node: Shell Quoting629063 +Node: Data File Management630464 +Node: Filetrans Function631096 +Node: Rewind Function635192 +Node: File Checking636578 +Ref: File Checking-Footnote-1637911 +Node: Empty Files638112 +Node: Ignoring Assigns640091 +Node: Getopt Function641641 +Ref: Getopt Function-Footnote-1653105 +Node: Passwd Functions653305 +Ref: Passwd Functions-Footnote-1662145 +Node: Group Functions662233 +Ref: Group Functions-Footnote-1670130 +Node: Walking Arrays670335 +Node: Library Functions Summary673341 +Node: Library Exercises674743 +Node: Sample Programs676023 +Node: Running Examples676793 +Node: Clones677521 +Node: Cut Program678745 +Node: Egrep Program688465 +Ref: Egrep Program-Footnote-1695968 +Node: Id Program696078 +Node: Split Program699754 +Ref: Split Program-Footnote-1703208 +Node: Tee Program703336 +Node: Uniq Program706125 +Node: Wc Program713544 +Ref: Wc Program-Footnote-1717794 +Node: Miscellaneous Programs717888 +Node: Dupword Program719101 +Node: Alarm Program721132 +Node: Translate Program725937 +Ref: Translate Program-Footnote-1730500 +Node: Labels Program730770 +Ref: Labels Program-Footnote-1734121 +Node: Word Sorting734205 +Node: History Sorting738275 +Node: Extract Program740110 +Node: Simple Sed747634 +Node: Igawk Program750704 +Ref: Igawk Program-Footnote-1765030 +Ref: Igawk Program-Footnote-2765231 +Ref: Igawk Program-Footnote-3765353 +Node: Anagram Program765468 +Node: Signature Program768529 +Node: Programs Summary769776 +Node: Programs Exercises770997 +Ref: Programs Exercises-Footnote-1775128 +Node: Advanced Features775219 +Node: Nondecimal Data777201 +Node: Array Sorting778791 +Node: Controlling Array Traversal779491 +Ref: Controlling Array Traversal-Footnote-1787857 +Node: Array Sorting Functions787975 +Ref: Array Sorting Functions-Footnote-1791861 +Node: Two-way I/O792057 +Ref: Two-way I/O-Footnote-1797002 +Ref: Two-way I/O-Footnote-2797188 +Node: TCP/IP Networking797270 +Node: Profiling800142 +Node: Advanced Features Summary807683 +Node: Internationalization809616 +Node: I18N and L10N811096 +Node: Explaining gettext811782 +Ref: Explaining gettext-Footnote-1816807 +Ref: Explaining gettext-Footnote-2816991 +Node: Programmer i18n817156 +Ref: Programmer i18n-Footnote-1822032 +Node: Translator i18n822081 +Node: String Extraction822875 +Ref: String Extraction-Footnote-1824006 +Node: Printf Ordering824092 +Ref: Printf Ordering-Footnote-1826878 +Node: I18N Portability826942 +Ref: I18N Portability-Footnote-1829398 +Node: I18N Example829461 +Ref: I18N Example-Footnote-1832264 +Node: Gawk I18N832336 +Node: I18N Summary832980 +Node: Debugger834320 +Node: Debugging835342 +Node: Debugging Concepts835783 +Node: Debugging Terms837593 +Node: Awk Debugging840165 +Node: Sample Debugging Session841071 +Node: Debugger Invocation841605 +Node: Finding The Bug842990 +Node: List of Debugger Commands849469 +Node: Breakpoint Control850801 +Node: Debugger Execution Control854478 +Node: Viewing And Changing Data857837 +Node: Execution Stack861213 +Node: Debugger Info862848 +Node: Miscellaneous Debugger Commands866893 +Node: Readline Support871894 +Node: Limitations872788 +Node: Debugging Summary874903 +Node: Arbitrary Precision Arithmetic876077 +Node: Computer Arithmetic877493 +Ref: table-numeric-ranges881070 +Ref: Computer Arithmetic-Footnote-1881594 +Node: Math Definitions881651 +Ref: table-ieee-formats884946 +Ref: Math Definitions-Footnote-1885550 +Node: MPFR features885655 +Node: FP Math Caution887326 +Ref: FP Math Caution-Footnote-1888376 +Node: Inexactness of computations888745 +Node: Inexact representation889704 +Node: Comparing FP Values891062 +Node: Errors accumulate892144 +Node: Getting Accuracy893576 +Node: Try To Round896280 +Node: Setting precision897179 +Ref: table-predefined-precision-strings897863 +Node: Setting the rounding mode899692 +Ref: table-gawk-rounding-modes900056 +Ref: Setting the rounding mode-Footnote-1903508 +Node: Arbitrary Precision Integers903687 +Ref: Arbitrary Precision Integers-Footnote-1906671 +Node: POSIX Floating Point Problems906820 +Ref: POSIX Floating Point Problems-Footnote-1910699 +Node: Floating point summary910737 +Node: Dynamic Extensions912924 +Node: Extension Intro914476 +Node: Plugin License915741 +Node: Extension Mechanism Outline916538 +Ref: figure-load-extension916966 +Ref: figure-register-new-function918446 +Ref: figure-call-new-function919450 +Node: Extension API Description921437 +Node: Extension API Functions Introduction922887 +Node: General Data Types927708 +Ref: General Data Types-Footnote-1933608 +Node: Memory Allocation Functions933907 +Ref: Memory Allocation Functions-Footnote-1936746 +Node: Constructor Functions936845 +Node: Registration Functions938584 +Node: Extension Functions939269 +Node: Exit Callback Functions941566 +Node: Extension Version String942814 +Node: Input Parsers943477 +Node: Output Wrappers953352 +Node: Two-way processors957865 +Node: Printing Messages960128 +Ref: Printing Messages-Footnote-1961204 +Node: Updating `ERRNO'961356 +Node: Requesting Values962096 +Ref: table-value-types-returned962823 +Node: Accessing Parameters963780 +Node: Symbol Table Access965014 +Node: Symbol table by name965528 +Node: Symbol table by cookie967548 +Ref: Symbol table by cookie-Footnote-1971693 +Node: Cached values971756 +Ref: Cached values-Footnote-1975252 +Node: Array Manipulation975343 +Ref: Array Manipulation-Footnote-1976441 +Node: Array Data Types976478 +Ref: Array Data Types-Footnote-1979133 +Node: Array Functions979225 +Node: Flattening Arrays983084 +Node: Creating Arrays989986 +Node: Extension API Variables994757 +Node: Extension Versioning995393 +Node: Extension API Informational Variables997284 +Node: Extension API Boilerplate998349 +Node: Finding Extensions1002158 +Node: Extension Example1002718 +Node: Internal File Description1003490 +Node: Internal File Ops1007557 +Ref: Internal File Ops-Footnote-11019308 +Node: Using Internal File Ops1019448 +Ref: Using Internal File Ops-Footnote-11021831 +Node: Extension Samples1022104 +Node: Extension Sample File Functions1023632 +Node: Extension Sample Fnmatch1031313 +Node: Extension Sample Fork1032801 +Node: Extension Sample Inplace1034016 +Node: Extension Sample Ord1036102 +Node: Extension Sample Readdir1036938 +Ref: table-readdir-file-types1037815 +Node: Extension Sample Revout1038626 +Node: Extension Sample Rev2way1039215 +Node: Extension Sample Read write array1039955 +Node: Extension Sample Readfile1041895 +Node: Extension Sample Time1042990 +Node: Extension Sample API Tests1044338 +Node: gawkextlib1044829 +Node: Extension summary1047507 +Node: Extension Exercises1051196 +Node: Language History1052692 +Node: V7/SVR3.11054348 +Node: SVR41056501 +Node: POSIX1057935 +Node: BTL1059316 +Node: POSIX/GNU1060047 +Node: Feature History1065568 +Node: Common Extensions1078666 +Node: Ranges and Locales1080038 +Ref: Ranges and Locales-Footnote-11084657 +Ref: Ranges and Locales-Footnote-21084684 +Ref: Ranges and Locales-Footnote-31084919 +Node: Contributors1085140 +Node: History summary1090680 +Node: Installation1092059 +Node: Gawk Distribution1093005 +Node: Getting1093489 +Node: Extracting1094312 +Node: Distribution contents1095949 +Node: Unix Installation1101703 +Node: Quick Installation1102320 +Node: Additional Configuration Options1104744 +Node: Configuration Philosophy1106547 +Node: Non-Unix Installation1108916 +Node: PC Installation1109374 +Node: PC Binary Installation1110694 +Node: PC Compiling1112542 +Ref: PC Compiling-Footnote-11115563 +Node: PC Testing1115672 +Node: PC Using1116848 +Node: Cygwin1120963 +Node: MSYS1121733 +Node: VMS Installation1122234 +Node: VMS Compilation1123026 +Ref: VMS Compilation-Footnote-11124255 +Node: VMS Dynamic Extensions1124313 +Node: VMS Installation Details1125997 +Node: VMS Running1128248 +Node: VMS GNV1131088 +Node: VMS Old Gawk1131823 +Node: Bugs1132293 +Node: Other Versions1136182 +Node: Installation summary1142616 +Node: Notes1143675 +Node: Compatibility Mode1144540 +Node: Additions1145322 +Node: Accessing The Source1146247 +Node: Adding Code1147682 +Node: New Ports1153839 +Node: Derived Files1158321 +Ref: Derived Files-Footnote-11163796 +Ref: Derived Files-Footnote-21163830 +Ref: Derived Files-Footnote-31164426 +Node: Future Extensions1164540 +Node: Implementation Limitations1165146 +Node: Extension Design1166394 +Node: Old Extension Problems1167548 +Ref: Old Extension Problems-Footnote-11169065 +Node: Extension New Mechanism Goals1169122 +Ref: Extension New Mechanism Goals-Footnote-11172482 +Node: Extension Other Design Decisions1172671 +Node: Extension Future Growth1174779 +Node: Old Extension Mechanism1175615 +Node: Notes summary1177377 +Node: Basic Concepts1178563 +Node: Basic High Level1179244 +Ref: figure-general-flow1179516 +Ref: figure-process-flow1180115 +Ref: Basic High Level-Footnote-11183344 +Node: Basic Data Typing1183529 +Node: Glossary1186857 +Node: Copying1218786 +Node: GNU Free Documentation License1256342 +Node: Index1281478  End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 80f8528d..d23b2128 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -20344,10 +20344,23 @@ Remember that you must supply a leading @samp{@@} in front of an indirect functi Starting with @value{PVERSION} 4.1.2 of @command{gawk}, indirect function calls may also be used with built-in functions and with extension functions -(@pxref{Dynamic Extensions}). The only thing you cannot do is pass a regular -expression constant to a built-in function through an indirect function -call.@footnote{This may change in a future version; recheck the documentation that -comes with your version of @command{gawk} to see if it has.} +(@pxref{Dynamic Extensions}). There are some limitations when calling +built-in functions indirectly, as follows. + +@itemize @value{BULLET} +@item +You cannot pass a regular expression constant to a built-in function +through an indirect function call.@footnote{This may change in a future +version; recheck the documentation that comes with your version of +@command{gawk} to see if it has.} This applies to the @code{sub()}, +@code{gsub()}, @code{gensub()}, @code{match()}, @code{split()} and +@code{patsplit()} functions. + +@item +If calling @code{sub()} or @code{gsub()}, you may only pass two arguments, +since those functions are unusual in that they update their third argument. +This means that @code{$0} will be updated. +@end itemize @command{gawk} does its best to make indirect function calls efficient. For example, in the following case: diff --git a/doc/gawktexi.in b/doc/gawktexi.in index cf669976..8e7d4010 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -19465,10 +19465,23 @@ Remember that you must supply a leading @samp{@@} in front of an indirect functi Starting with @value{PVERSION} 4.1.2 of @command{gawk}, indirect function calls may also be used with built-in functions and with extension functions -(@pxref{Dynamic Extensions}). The only thing you cannot do is pass a regular -expression constant to a built-in function through an indirect function -call.@footnote{This may change in a future version; recheck the documentation that -comes with your version of @command{gawk} to see if it has.} +(@pxref{Dynamic Extensions}). There are some limitations when calling +built-in functions indirectly, as follows. + +@itemize @value{BULLET} +@item +You cannot pass a regular expression constant to a built-in function +through an indirect function call.@footnote{This may change in a future +version; recheck the documentation that comes with your version of +@command{gawk} to see if it has.} This applies to the @code{sub()}, +@code{gsub()}, @code{gensub()}, @code{match()}, @code{split()} and +@code{patsplit()} functions. + +@item +If calling @code{sub()} or @code{gsub()}, you may only pass two arguments, +since those functions are unusual in that they update their third argument. +This means that @code{$0} will be updated. +@end itemize @command{gawk} does its best to make indirect function calls efficient. For example, in the following case: -- cgit v1.2.1 From 9730efeabb2116fdf7e93b4553825ba147f5f523 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 31 Mar 2015 22:27:48 +0300 Subject: Small doc fix. --- doc/ChangeLog | 3 +- doc/gawk.info | 658 ++++++++++++++++++++++++++++---------------------------- doc/gawk.texi | 4 +- doc/gawktexi.in | 4 +- 4 files changed, 335 insertions(+), 334 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 2f5dabb0..982db16c 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,7 +1,8 @@ 2015-03-31 Arnold D. Robbins * gawktexi.in: Update discussion of calling built-in functions - indirectly. + indirectly. Small additional fix relating to rand(). Thanks + to Antonio Colombo. 2015-03-24 Arnold D. Robbins diff --git a/doc/gawk.info b/doc/gawk.info index 9b6a46fc..b927b445 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -11929,9 +11929,9 @@ brackets ([ ]): return int(n * rand()) } - The multiplication produces a random number greater than zero and - less than `n'. Using `int()', this result is made into an integer - between zero and `n' - 1, inclusive. + The multiplication produces a random number greater than or equal + to zero and less than `n'. Using `int()', this result is made into + an integer between zero and `n' - 1, inclusive. The following example uses a similar function to produce random integers between one and N. This program prints a new random @@ -34746,331 +34746,331 @@ Node: Functions499087 Node: Built-in500126 Node: Calling Built-in501204 Node: Numeric Functions503199 -Ref: Numeric Functions-Footnote-1507215 -Ref: Numeric Functions-Footnote-2507572 -Ref: Numeric Functions-Footnote-3507620 -Node: String Functions507892 -Ref: String Functions-Footnote-1531393 -Ref: String Functions-Footnote-2531522 -Ref: String Functions-Footnote-3531770 -Node: Gory Details531857 -Ref: table-sub-escapes533638 -Ref: table-sub-proposed535153 -Ref: table-posix-sub536515 -Ref: table-gensub-escapes538052 -Ref: Gory Details-Footnote-1538885 -Node: I/O Functions539036 -Ref: I/O Functions-Footnote-1546272 -Node: Time Functions546419 -Ref: Time Functions-Footnote-1556928 -Ref: Time Functions-Footnote-2556996 -Ref: Time Functions-Footnote-3557154 -Ref: Time Functions-Footnote-4557265 -Ref: Time Functions-Footnote-5557377 -Ref: Time Functions-Footnote-6557604 -Node: Bitwise Functions557870 -Ref: table-bitwise-ops558432 -Ref: Bitwise Functions-Footnote-1562760 -Node: Type Functions562932 -Node: I18N Functions564084 -Node: User-defined565731 -Node: Definition Syntax566536 -Ref: Definition Syntax-Footnote-1572195 -Node: Function Example572266 -Ref: Function Example-Footnote-1575187 -Node: Function Caveats575209 -Node: Calling A Function575727 -Node: Variable Scope576685 -Node: Pass By Value/Reference579678 -Node: Return Statement583175 -Node: Dynamic Typing586154 -Node: Indirect Calls587083 -Ref: Indirect Calls-Footnote-1597326 -Node: Functions Summary597454 -Node: Library Functions600156 -Ref: Library Functions-Footnote-1603764 -Ref: Library Functions-Footnote-2603907 -Node: Library Names604078 -Ref: Library Names-Footnote-1607536 -Ref: Library Names-Footnote-2607759 -Node: General Functions607845 -Node: Strtonum Function608948 -Node: Assert Function611970 -Node: Round Function615294 -Node: Cliff Random Function616835 -Node: Ordinal Functions617851 -Ref: Ordinal Functions-Footnote-1620914 -Ref: Ordinal Functions-Footnote-2621166 -Node: Join Function621377 -Ref: Join Function-Footnote-1623147 -Node: Getlocaltime Function623347 -Node: Readfile Function627091 -Node: Shell Quoting629063 -Node: Data File Management630464 -Node: Filetrans Function631096 -Node: Rewind Function635192 -Node: File Checking636578 -Ref: File Checking-Footnote-1637911 -Node: Empty Files638112 -Node: Ignoring Assigns640091 -Node: Getopt Function641641 -Ref: Getopt Function-Footnote-1653105 -Node: Passwd Functions653305 -Ref: Passwd Functions-Footnote-1662145 -Node: Group Functions662233 -Ref: Group Functions-Footnote-1670130 -Node: Walking Arrays670335 -Node: Library Functions Summary673341 -Node: Library Exercises674743 -Node: Sample Programs676023 -Node: Running Examples676793 -Node: Clones677521 -Node: Cut Program678745 -Node: Egrep Program688465 -Ref: Egrep Program-Footnote-1695968 -Node: Id Program696078 -Node: Split Program699754 -Ref: Split Program-Footnote-1703208 -Node: Tee Program703336 -Node: Uniq Program706125 -Node: Wc Program713544 -Ref: Wc Program-Footnote-1717794 -Node: Miscellaneous Programs717888 -Node: Dupword Program719101 -Node: Alarm Program721132 -Node: Translate Program725937 -Ref: Translate Program-Footnote-1730500 -Node: Labels Program730770 -Ref: Labels Program-Footnote-1734121 -Node: Word Sorting734205 -Node: History Sorting738275 -Node: Extract Program740110 -Node: Simple Sed747634 -Node: Igawk Program750704 -Ref: Igawk Program-Footnote-1765030 -Ref: Igawk Program-Footnote-2765231 -Ref: Igawk Program-Footnote-3765353 -Node: Anagram Program765468 -Node: Signature Program768529 -Node: Programs Summary769776 -Node: Programs Exercises770997 -Ref: Programs Exercises-Footnote-1775128 -Node: Advanced Features775219 -Node: Nondecimal Data777201 -Node: Array Sorting778791 -Node: Controlling Array Traversal779491 -Ref: Controlling Array Traversal-Footnote-1787857 -Node: Array Sorting Functions787975 -Ref: Array Sorting Functions-Footnote-1791861 -Node: Two-way I/O792057 -Ref: Two-way I/O-Footnote-1797002 -Ref: Two-way I/O-Footnote-2797188 -Node: TCP/IP Networking797270 -Node: Profiling800142 -Node: Advanced Features Summary807683 -Node: Internationalization809616 -Node: I18N and L10N811096 -Node: Explaining gettext811782 -Ref: Explaining gettext-Footnote-1816807 -Ref: Explaining gettext-Footnote-2816991 -Node: Programmer i18n817156 -Ref: Programmer i18n-Footnote-1822032 -Node: Translator i18n822081 -Node: String Extraction822875 -Ref: String Extraction-Footnote-1824006 -Node: Printf Ordering824092 -Ref: Printf Ordering-Footnote-1826878 -Node: I18N Portability826942 -Ref: I18N Portability-Footnote-1829398 -Node: I18N Example829461 -Ref: I18N Example-Footnote-1832264 -Node: Gawk I18N832336 -Node: I18N Summary832980 -Node: Debugger834320 -Node: Debugging835342 -Node: Debugging Concepts835783 -Node: Debugging Terms837593 -Node: Awk Debugging840165 -Node: Sample Debugging Session841071 -Node: Debugger Invocation841605 -Node: Finding The Bug842990 -Node: List of Debugger Commands849469 -Node: Breakpoint Control850801 -Node: Debugger Execution Control854478 -Node: Viewing And Changing Data857837 -Node: Execution Stack861213 -Node: Debugger Info862848 -Node: Miscellaneous Debugger Commands866893 -Node: Readline Support871894 -Node: Limitations872788 -Node: Debugging Summary874903 -Node: Arbitrary Precision Arithmetic876077 -Node: Computer Arithmetic877493 -Ref: table-numeric-ranges881070 -Ref: Computer Arithmetic-Footnote-1881594 -Node: Math Definitions881651 -Ref: table-ieee-formats884946 -Ref: Math Definitions-Footnote-1885550 -Node: MPFR features885655 -Node: FP Math Caution887326 -Ref: FP Math Caution-Footnote-1888376 -Node: Inexactness of computations888745 -Node: Inexact representation889704 -Node: Comparing FP Values891062 -Node: Errors accumulate892144 -Node: Getting Accuracy893576 -Node: Try To Round896280 -Node: Setting precision897179 -Ref: table-predefined-precision-strings897863 -Node: Setting the rounding mode899692 -Ref: table-gawk-rounding-modes900056 -Ref: Setting the rounding mode-Footnote-1903508 -Node: Arbitrary Precision Integers903687 -Ref: Arbitrary Precision Integers-Footnote-1906671 -Node: POSIX Floating Point Problems906820 -Ref: POSIX Floating Point Problems-Footnote-1910699 -Node: Floating point summary910737 -Node: Dynamic Extensions912924 -Node: Extension Intro914476 -Node: Plugin License915741 -Node: Extension Mechanism Outline916538 -Ref: figure-load-extension916966 -Ref: figure-register-new-function918446 -Ref: figure-call-new-function919450 -Node: Extension API Description921437 -Node: Extension API Functions Introduction922887 -Node: General Data Types927708 -Ref: General Data Types-Footnote-1933608 -Node: Memory Allocation Functions933907 -Ref: Memory Allocation Functions-Footnote-1936746 -Node: Constructor Functions936845 -Node: Registration Functions938584 -Node: Extension Functions939269 -Node: Exit Callback Functions941566 -Node: Extension Version String942814 -Node: Input Parsers943477 -Node: Output Wrappers953352 -Node: Two-way processors957865 -Node: Printing Messages960128 -Ref: Printing Messages-Footnote-1961204 -Node: Updating `ERRNO'961356 -Node: Requesting Values962096 -Ref: table-value-types-returned962823 -Node: Accessing Parameters963780 -Node: Symbol Table Access965014 -Node: Symbol table by name965528 -Node: Symbol table by cookie967548 -Ref: Symbol table by cookie-Footnote-1971693 -Node: Cached values971756 -Ref: Cached values-Footnote-1975252 -Node: Array Manipulation975343 -Ref: Array Manipulation-Footnote-1976441 -Node: Array Data Types976478 -Ref: Array Data Types-Footnote-1979133 -Node: Array Functions979225 -Node: Flattening Arrays983084 -Node: Creating Arrays989986 -Node: Extension API Variables994757 -Node: Extension Versioning995393 -Node: Extension API Informational Variables997284 -Node: Extension API Boilerplate998349 -Node: Finding Extensions1002158 -Node: Extension Example1002718 -Node: Internal File Description1003490 -Node: Internal File Ops1007557 -Ref: Internal File Ops-Footnote-11019308 -Node: Using Internal File Ops1019448 -Ref: Using Internal File Ops-Footnote-11021831 -Node: Extension Samples1022104 -Node: Extension Sample File Functions1023632 -Node: Extension Sample Fnmatch1031313 -Node: Extension Sample Fork1032801 -Node: Extension Sample Inplace1034016 -Node: Extension Sample Ord1036102 -Node: Extension Sample Readdir1036938 -Ref: table-readdir-file-types1037815 -Node: Extension Sample Revout1038626 -Node: Extension Sample Rev2way1039215 -Node: Extension Sample Read write array1039955 -Node: Extension Sample Readfile1041895 -Node: Extension Sample Time1042990 -Node: Extension Sample API Tests1044338 -Node: gawkextlib1044829 -Node: Extension summary1047507 -Node: Extension Exercises1051196 -Node: Language History1052692 -Node: V7/SVR3.11054348 -Node: SVR41056501 -Node: POSIX1057935 -Node: BTL1059316 -Node: POSIX/GNU1060047 -Node: Feature History1065568 -Node: Common Extensions1078666 -Node: Ranges and Locales1080038 -Ref: Ranges and Locales-Footnote-11084657 -Ref: Ranges and Locales-Footnote-21084684 -Ref: Ranges and Locales-Footnote-31084919 -Node: Contributors1085140 -Node: History summary1090680 -Node: Installation1092059 -Node: Gawk Distribution1093005 -Node: Getting1093489 -Node: Extracting1094312 -Node: Distribution contents1095949 -Node: Unix Installation1101703 -Node: Quick Installation1102320 -Node: Additional Configuration Options1104744 -Node: Configuration Philosophy1106547 -Node: Non-Unix Installation1108916 -Node: PC Installation1109374 -Node: PC Binary Installation1110694 -Node: PC Compiling1112542 -Ref: PC Compiling-Footnote-11115563 -Node: PC Testing1115672 -Node: PC Using1116848 -Node: Cygwin1120963 -Node: MSYS1121733 -Node: VMS Installation1122234 -Node: VMS Compilation1123026 -Ref: VMS Compilation-Footnote-11124255 -Node: VMS Dynamic Extensions1124313 -Node: VMS Installation Details1125997 -Node: VMS Running1128248 -Node: VMS GNV1131088 -Node: VMS Old Gawk1131823 -Node: Bugs1132293 -Node: Other Versions1136182 -Node: Installation summary1142616 -Node: Notes1143675 -Node: Compatibility Mode1144540 -Node: Additions1145322 -Node: Accessing The Source1146247 -Node: Adding Code1147682 -Node: New Ports1153839 -Node: Derived Files1158321 -Ref: Derived Files-Footnote-11163796 -Ref: Derived Files-Footnote-21163830 -Ref: Derived Files-Footnote-31164426 -Node: Future Extensions1164540 -Node: Implementation Limitations1165146 -Node: Extension Design1166394 -Node: Old Extension Problems1167548 -Ref: Old Extension Problems-Footnote-11169065 -Node: Extension New Mechanism Goals1169122 -Ref: Extension New Mechanism Goals-Footnote-11172482 -Node: Extension Other Design Decisions1172671 -Node: Extension Future Growth1174779 -Node: Old Extension Mechanism1175615 -Node: Notes summary1177377 -Node: Basic Concepts1178563 -Node: Basic High Level1179244 -Ref: figure-general-flow1179516 -Ref: figure-process-flow1180115 -Ref: Basic High Level-Footnote-11183344 -Node: Basic Data Typing1183529 -Node: Glossary1186857 -Node: Copying1218786 -Node: GNU Free Documentation License1256342 -Node: Index1281478 +Ref: Numeric Functions-Footnote-1507227 +Ref: Numeric Functions-Footnote-2507584 +Ref: Numeric Functions-Footnote-3507632 +Node: String Functions507904 +Ref: String Functions-Footnote-1531405 +Ref: String Functions-Footnote-2531534 +Ref: String Functions-Footnote-3531782 +Node: Gory Details531869 +Ref: table-sub-escapes533650 +Ref: table-sub-proposed535165 +Ref: table-posix-sub536527 +Ref: table-gensub-escapes538064 +Ref: Gory Details-Footnote-1538897 +Node: I/O Functions539048 +Ref: I/O Functions-Footnote-1546284 +Node: Time Functions546431 +Ref: Time Functions-Footnote-1556940 +Ref: Time Functions-Footnote-2557008 +Ref: Time Functions-Footnote-3557166 +Ref: Time Functions-Footnote-4557277 +Ref: Time Functions-Footnote-5557389 +Ref: Time Functions-Footnote-6557616 +Node: Bitwise Functions557882 +Ref: table-bitwise-ops558444 +Ref: Bitwise Functions-Footnote-1562772 +Node: Type Functions562944 +Node: I18N Functions564096 +Node: User-defined565743 +Node: Definition Syntax566548 +Ref: Definition Syntax-Footnote-1572207 +Node: Function Example572278 +Ref: Function Example-Footnote-1575199 +Node: Function Caveats575221 +Node: Calling A Function575739 +Node: Variable Scope576697 +Node: Pass By Value/Reference579690 +Node: Return Statement583187 +Node: Dynamic Typing586166 +Node: Indirect Calls587095 +Ref: Indirect Calls-Footnote-1597338 +Node: Functions Summary597466 +Node: Library Functions600168 +Ref: Library Functions-Footnote-1603776 +Ref: Library Functions-Footnote-2603919 +Node: Library Names604090 +Ref: Library Names-Footnote-1607548 +Ref: Library Names-Footnote-2607771 +Node: General Functions607857 +Node: Strtonum Function608960 +Node: Assert Function611982 +Node: Round Function615306 +Node: Cliff Random Function616847 +Node: Ordinal Functions617863 +Ref: Ordinal Functions-Footnote-1620926 +Ref: Ordinal Functions-Footnote-2621178 +Node: Join Function621389 +Ref: Join Function-Footnote-1623159 +Node: Getlocaltime Function623359 +Node: Readfile Function627103 +Node: Shell Quoting629075 +Node: Data File Management630476 +Node: Filetrans Function631108 +Node: Rewind Function635204 +Node: File Checking636590 +Ref: File Checking-Footnote-1637923 +Node: Empty Files638124 +Node: Ignoring Assigns640103 +Node: Getopt Function641653 +Ref: Getopt Function-Footnote-1653117 +Node: Passwd Functions653317 +Ref: Passwd Functions-Footnote-1662157 +Node: Group Functions662245 +Ref: Group Functions-Footnote-1670142 +Node: Walking Arrays670347 +Node: Library Functions Summary673353 +Node: Library Exercises674755 +Node: Sample Programs676035 +Node: Running Examples676805 +Node: Clones677533 +Node: Cut Program678757 +Node: Egrep Program688477 +Ref: Egrep Program-Footnote-1695980 +Node: Id Program696090 +Node: Split Program699766 +Ref: Split Program-Footnote-1703220 +Node: Tee Program703348 +Node: Uniq Program706137 +Node: Wc Program713556 +Ref: Wc Program-Footnote-1717806 +Node: Miscellaneous Programs717900 +Node: Dupword Program719113 +Node: Alarm Program721144 +Node: Translate Program725949 +Ref: Translate Program-Footnote-1730512 +Node: Labels Program730782 +Ref: Labels Program-Footnote-1734133 +Node: Word Sorting734217 +Node: History Sorting738287 +Node: Extract Program740122 +Node: Simple Sed747646 +Node: Igawk Program750716 +Ref: Igawk Program-Footnote-1765042 +Ref: Igawk Program-Footnote-2765243 +Ref: Igawk Program-Footnote-3765365 +Node: Anagram Program765480 +Node: Signature Program768541 +Node: Programs Summary769788 +Node: Programs Exercises771009 +Ref: Programs Exercises-Footnote-1775140 +Node: Advanced Features775231 +Node: Nondecimal Data777213 +Node: Array Sorting778803 +Node: Controlling Array Traversal779503 +Ref: Controlling Array Traversal-Footnote-1787869 +Node: Array Sorting Functions787987 +Ref: Array Sorting Functions-Footnote-1791873 +Node: Two-way I/O792069 +Ref: Two-way I/O-Footnote-1797014 +Ref: Two-way I/O-Footnote-2797200 +Node: TCP/IP Networking797282 +Node: Profiling800154 +Node: Advanced Features Summary807695 +Node: Internationalization809628 +Node: I18N and L10N811108 +Node: Explaining gettext811794 +Ref: Explaining gettext-Footnote-1816819 +Ref: Explaining gettext-Footnote-2817003 +Node: Programmer i18n817168 +Ref: Programmer i18n-Footnote-1822044 +Node: Translator i18n822093 +Node: String Extraction822887 +Ref: String Extraction-Footnote-1824018 +Node: Printf Ordering824104 +Ref: Printf Ordering-Footnote-1826890 +Node: I18N Portability826954 +Ref: I18N Portability-Footnote-1829410 +Node: I18N Example829473 +Ref: I18N Example-Footnote-1832276 +Node: Gawk I18N832348 +Node: I18N Summary832992 +Node: Debugger834332 +Node: Debugging835354 +Node: Debugging Concepts835795 +Node: Debugging Terms837605 +Node: Awk Debugging840177 +Node: Sample Debugging Session841083 +Node: Debugger Invocation841617 +Node: Finding The Bug843002 +Node: List of Debugger Commands849481 +Node: Breakpoint Control850813 +Node: Debugger Execution Control854490 +Node: Viewing And Changing Data857849 +Node: Execution Stack861225 +Node: Debugger Info862860 +Node: Miscellaneous Debugger Commands866905 +Node: Readline Support871906 +Node: Limitations872800 +Node: Debugging Summary874915 +Node: Arbitrary Precision Arithmetic876089 +Node: Computer Arithmetic877505 +Ref: table-numeric-ranges881082 +Ref: Computer Arithmetic-Footnote-1881606 +Node: Math Definitions881663 +Ref: table-ieee-formats884958 +Ref: Math Definitions-Footnote-1885562 +Node: MPFR features885667 +Node: FP Math Caution887338 +Ref: FP Math Caution-Footnote-1888388 +Node: Inexactness of computations888757 +Node: Inexact representation889716 +Node: Comparing FP Values891074 +Node: Errors accumulate892156 +Node: Getting Accuracy893588 +Node: Try To Round896292 +Node: Setting precision897191 +Ref: table-predefined-precision-strings897875 +Node: Setting the rounding mode899704 +Ref: table-gawk-rounding-modes900068 +Ref: Setting the rounding mode-Footnote-1903520 +Node: Arbitrary Precision Integers903699 +Ref: Arbitrary Precision Integers-Footnote-1906683 +Node: POSIX Floating Point Problems906832 +Ref: POSIX Floating Point Problems-Footnote-1910711 +Node: Floating point summary910749 +Node: Dynamic Extensions912936 +Node: Extension Intro914488 +Node: Plugin License915753 +Node: Extension Mechanism Outline916550 +Ref: figure-load-extension916978 +Ref: figure-register-new-function918458 +Ref: figure-call-new-function919462 +Node: Extension API Description921449 +Node: Extension API Functions Introduction922899 +Node: General Data Types927720 +Ref: General Data Types-Footnote-1933620 +Node: Memory Allocation Functions933919 +Ref: Memory Allocation Functions-Footnote-1936758 +Node: Constructor Functions936857 +Node: Registration Functions938596 +Node: Extension Functions939281 +Node: Exit Callback Functions941578 +Node: Extension Version String942826 +Node: Input Parsers943489 +Node: Output Wrappers953364 +Node: Two-way processors957877 +Node: Printing Messages960140 +Ref: Printing Messages-Footnote-1961216 +Node: Updating `ERRNO'961368 +Node: Requesting Values962108 +Ref: table-value-types-returned962835 +Node: Accessing Parameters963792 +Node: Symbol Table Access965026 +Node: Symbol table by name965540 +Node: Symbol table by cookie967560 +Ref: Symbol table by cookie-Footnote-1971705 +Node: Cached values971768 +Ref: Cached values-Footnote-1975264 +Node: Array Manipulation975355 +Ref: Array Manipulation-Footnote-1976453 +Node: Array Data Types976490 +Ref: Array Data Types-Footnote-1979145 +Node: Array Functions979237 +Node: Flattening Arrays983096 +Node: Creating Arrays989998 +Node: Extension API Variables994769 +Node: Extension Versioning995405 +Node: Extension API Informational Variables997296 +Node: Extension API Boilerplate998361 +Node: Finding Extensions1002170 +Node: Extension Example1002730 +Node: Internal File Description1003502 +Node: Internal File Ops1007569 +Ref: Internal File Ops-Footnote-11019320 +Node: Using Internal File Ops1019460 +Ref: Using Internal File Ops-Footnote-11021843 +Node: Extension Samples1022116 +Node: Extension Sample File Functions1023644 +Node: Extension Sample Fnmatch1031325 +Node: Extension Sample Fork1032813 +Node: Extension Sample Inplace1034028 +Node: Extension Sample Ord1036114 +Node: Extension Sample Readdir1036950 +Ref: table-readdir-file-types1037827 +Node: Extension Sample Revout1038638 +Node: Extension Sample Rev2way1039227 +Node: Extension Sample Read write array1039967 +Node: Extension Sample Readfile1041907 +Node: Extension Sample Time1043002 +Node: Extension Sample API Tests1044350 +Node: gawkextlib1044841 +Node: Extension summary1047519 +Node: Extension Exercises1051208 +Node: Language History1052704 +Node: V7/SVR3.11054360 +Node: SVR41056513 +Node: POSIX1057947 +Node: BTL1059328 +Node: POSIX/GNU1060059 +Node: Feature History1065580 +Node: Common Extensions1078678 +Node: Ranges and Locales1080050 +Ref: Ranges and Locales-Footnote-11084669 +Ref: Ranges and Locales-Footnote-21084696 +Ref: Ranges and Locales-Footnote-31084931 +Node: Contributors1085152 +Node: History summary1090692 +Node: Installation1092071 +Node: Gawk Distribution1093017 +Node: Getting1093501 +Node: Extracting1094324 +Node: Distribution contents1095961 +Node: Unix Installation1101715 +Node: Quick Installation1102332 +Node: Additional Configuration Options1104756 +Node: Configuration Philosophy1106559 +Node: Non-Unix Installation1108928 +Node: PC Installation1109386 +Node: PC Binary Installation1110706 +Node: PC Compiling1112554 +Ref: PC Compiling-Footnote-11115575 +Node: PC Testing1115684 +Node: PC Using1116860 +Node: Cygwin1120975 +Node: MSYS1121745 +Node: VMS Installation1122246 +Node: VMS Compilation1123038 +Ref: VMS Compilation-Footnote-11124267 +Node: VMS Dynamic Extensions1124325 +Node: VMS Installation Details1126009 +Node: VMS Running1128260 +Node: VMS GNV1131100 +Node: VMS Old Gawk1131835 +Node: Bugs1132305 +Node: Other Versions1136194 +Node: Installation summary1142628 +Node: Notes1143687 +Node: Compatibility Mode1144552 +Node: Additions1145334 +Node: Accessing The Source1146259 +Node: Adding Code1147694 +Node: New Ports1153851 +Node: Derived Files1158333 +Ref: Derived Files-Footnote-11163808 +Ref: Derived Files-Footnote-21163842 +Ref: Derived Files-Footnote-31164438 +Node: Future Extensions1164552 +Node: Implementation Limitations1165158 +Node: Extension Design1166406 +Node: Old Extension Problems1167560 +Ref: Old Extension Problems-Footnote-11169077 +Node: Extension New Mechanism Goals1169134 +Ref: Extension New Mechanism Goals-Footnote-11172494 +Node: Extension Other Design Decisions1172683 +Node: Extension Future Growth1174791 +Node: Old Extension Mechanism1175627 +Node: Notes summary1177389 +Node: Basic Concepts1178575 +Node: Basic High Level1179256 +Ref: figure-general-flow1179528 +Ref: figure-process-flow1180127 +Ref: Basic High Level-Footnote-11183356 +Node: Basic Data Typing1183541 +Node: Glossary1186869 +Node: Copying1218798 +Node: GNU Free Documentation License1256354 +Node: Index1281490  End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index d23b2128..eb2e968b 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -16991,8 +16991,8 @@ function randint(n) @end example @noindent -The multiplication produces a random number greater than zero and less -than @code{n}. Using @code{int()}, this result is made into +The multiplication produces a random number greater than or equal to +zero and less than @code{n}. Using @code{int()}, this result is made into an integer between zero and @code{n} @minus{} 1, inclusive. The following example uses a similar function to produce random integers diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 8e7d4010..706754e2 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -16273,8 +16273,8 @@ function randint(n) @end example @noindent -The multiplication produces a random number greater than zero and less -than @code{n}. Using @code{int()}, this result is made into +The multiplication produces a random number greater than or equal to +zero and less than @code{n}. Using @code{int()}, this result is made into an integer between zero and @code{n} @minus{} 1, inclusive. The following example uses a similar function to produce random integers -- cgit v1.2.1 From ddc290584b39bab2c1edcec935a31ea12d343246 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Fri, 3 Apr 2015 09:08:54 +0300 Subject: Rename "div()" to "intdiv()". --- ChangeLog | 9 + awk.h | 4 +- awkgram.c | 6 +- awkgram.y | 6 +- awklib/eg/lib/div.awk | 17 -- awklib/eg/lib/intdiv.awk | 20 ++ awklib/eg/prog/pi.awk | 2 +- builtin.c | 12 +- doc/ChangeLog | 4 + doc/awkcard.in | 6 +- doc/gawk.1 | 16 +- doc/gawk.info | 711 ++++++++++++++++++++++++----------------------- doc/gawk.texi | 59 ++-- doc/gawktexi.in | 59 ++-- mpfr.c | 12 +- test/ChangeLog | 4 + test/id.ok | 2 +- test/mpfrsqrt.awk | 6 +- 18 files changed, 491 insertions(+), 464 deletions(-) delete mode 100644 awklib/eg/lib/div.awk create mode 100644 awklib/eg/lib/intdiv.awk diff --git a/ChangeLog b/ChangeLog index 9b2490bb..0a395564 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2015-04-02 Arnold D. Robbins + + Rename div() to intdiv(). + + * builtin.c (do_intdiv): Renamed from do_div. + * mfpr.c (do_mpfr_intdiv): Renamed from do_mpfr_div. + * awk.h: Update declarations. + * awkgram.y (tokentab, snode): Revise accordingly. + 2015-03-31 Arnold D. Robbins * awk.h (call_sub): Renamed from call_sub_func. diff --git a/awk.h b/awk.h index 384e6f16..6f812e71 100644 --- a/awk.h +++ b/awk.h @@ -1383,7 +1383,7 @@ extern AWKNUM nondec2awknum(char *str, size_t len); extern NODE *do_dcgettext(int nargs); extern NODE *do_dcngettext(int nargs); extern NODE *do_bindtextdomain(int nargs); -extern NODE *do_div(int nargs); +extern NODE *do_intdiv(int nargs); extern int strncasecmpmbs(const unsigned char *, const unsigned char *, size_t); /* eval.c */ @@ -1526,9 +1526,9 @@ extern NODE *do_mpfr_and(int); extern NODE *do_mpfr_atan2(int); extern NODE *do_mpfr_compl(int); extern NODE *do_mpfr_cos(int); -extern NODE *do_mpfr_div(int); extern NODE *do_mpfr_exp(int); extern NODE *do_mpfr_int(int); +extern NODE *do_mpfr_intdiv(int); extern NODE *do_mpfr_log(int); extern NODE *do_mpfr_lshift(int); extern NODE *do_mpfr_or(int); diff --git a/awkgram.c b/awkgram.c index 40f5d286..67c8feae 100644 --- a/awkgram.c +++ b/awkgram.c @@ -4287,7 +4287,6 @@ static const struct token tokentab[] = { {"dcngettext", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3)|A(4)|A(5), do_dcngettext, 0}, {"default", Op_K_default, LEX_DEFAULT, GAWKX, 0, 0}, {"delete", Op_K_delete, LEX_DELETE, NOT_OLD, 0, 0}, -{"div", Op_builtin, LEX_BUILTIN, GAWKX|A(3), do_div, MPF(div)}, {"do", Op_K_do, LEX_DO, NOT_OLD|BREAK|CONTINUE, 0, 0}, {"else", Op_K_else, LEX_ELSE, 0, 0, 0}, {"eval", Op_symbol, LEX_EVAL, 0, 0, 0}, @@ -4308,6 +4307,7 @@ static const struct token tokentab[] = { {"include", Op_symbol, LEX_INCLUDE, GAWKX, 0, 0}, {"index", Op_builtin, LEX_BUILTIN, A(2), do_index, 0}, {"int", Op_builtin, LEX_BUILTIN, A(1), do_int, MPF(int)}, +{"intdiv", Op_builtin, LEX_BUILTIN, GAWKX|A(3), do_intdiv, MPF(intdiv)}, {"isarray", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_isarray, 0}, {"length", Op_builtin, LEX_LENGTH, A(0)|A(1), do_length, 0}, {"load", Op_symbol, LEX_LOAD, GAWKX, 0, 0}, @@ -6481,9 +6481,9 @@ snode(INSTRUCTION *subn, INSTRUCTION *r) arg = subn->nexti; if (arg->nexti == arg->lasti && arg->nexti->opcode == Op_push) arg->nexti->opcode = Op_push_arg; /* argument may be array */ - } else if (r->builtin == do_div + } else if (r->builtin == do_intdiv #ifdef HAVE_MPFR - || r->builtin == MPF(div) + || r->builtin == MPF(intdiv) #endif ) { arg = subn->nexti->lasti->nexti->lasti->nexti; /* 3rd arg list */ diff --git a/awkgram.y b/awkgram.y index 4092a177..e04c2c65 100644 --- a/awkgram.y +++ b/awkgram.y @@ -1949,7 +1949,6 @@ static const struct token tokentab[] = { {"dcngettext", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3)|A(4)|A(5), do_dcngettext, 0}, {"default", Op_K_default, LEX_DEFAULT, GAWKX, 0, 0}, {"delete", Op_K_delete, LEX_DELETE, NOT_OLD, 0, 0}, -{"div", Op_builtin, LEX_BUILTIN, GAWKX|A(3), do_div, MPF(div)}, {"do", Op_K_do, LEX_DO, NOT_OLD|BREAK|CONTINUE, 0, 0}, {"else", Op_K_else, LEX_ELSE, 0, 0, 0}, {"eval", Op_symbol, LEX_EVAL, 0, 0, 0}, @@ -1970,6 +1969,7 @@ static const struct token tokentab[] = { {"include", Op_symbol, LEX_INCLUDE, GAWKX, 0, 0}, {"index", Op_builtin, LEX_BUILTIN, A(2), do_index, 0}, {"int", Op_builtin, LEX_BUILTIN, A(1), do_int, MPF(int)}, +{"intdiv", Op_builtin, LEX_BUILTIN, GAWKX|A(3), do_intdiv, MPF(intdiv)}, {"isarray", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_isarray, 0}, {"length", Op_builtin, LEX_LENGTH, A(0)|A(1), do_length, 0}, {"load", Op_symbol, LEX_LOAD, GAWKX, 0, 0}, @@ -4143,9 +4143,9 @@ snode(INSTRUCTION *subn, INSTRUCTION *r) arg = subn->nexti; if (arg->nexti == arg->lasti && arg->nexti->opcode == Op_push) arg->nexti->opcode = Op_push_arg; /* argument may be array */ - } else if (r->builtin == do_div + } else if (r->builtin == do_intdiv #ifdef HAVE_MPFR - || r->builtin == MPF(div) + || r->builtin == MPF(intdiv) #endif ) { arg = subn->nexti->lasti->nexti->lasti->nexti; /* 3rd arg list */ diff --git a/awklib/eg/lib/div.awk b/awklib/eg/lib/div.awk deleted file mode 100644 index 5939024d..00000000 --- a/awklib/eg/lib/div.awk +++ /dev/null @@ -1,17 +0,0 @@ -# div --- do integer division - -# -# Arnold Robbins, arnold@skeeve.com, Public Domain -# July, 2014 - -function div(numerator, denominator, result) -{ - split("", result) - - numerator = int(numerator) - denominator = int(denominator) - result["quotient"] = int(numerator / denominator) - result["remainder"] = int(numerator % denominator) - - return 0.0 -} diff --git a/awklib/eg/lib/intdiv.awk b/awklib/eg/lib/intdiv.awk new file mode 100644 index 00000000..dbc553b0 --- /dev/null +++ b/awklib/eg/lib/intdiv.awk @@ -0,0 +1,20 @@ +# intdiv --- do integer division + +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# July, 2014 +# +# Name changed from div() to intdiv() +# April, 2015 + +function intdiv(numerator, denominator, result) +{ + split("", result) + + numerator = int(numerator) + denominator = int(denominator) + result["quotient"] = int(numerator / denominator) + result["remainder"] = int(numerator % denominator) + + return 0.0 +} diff --git a/awklib/eg/prog/pi.awk b/awklib/eg/prog/pi.awk index 3297beff..e1b5bc4f 100644 --- a/awklib/eg/prog/pi.awk +++ b/awklib/eg/prog/pi.awk @@ -10,7 +10,7 @@ BEGIN { for (m = digits * 4; m > 0; --m) { d = m * 2 + 1 x = pi * m - div(x, d, result) + intdiv(x, d, result) pi = result["quotient"] pi = pi + two } diff --git a/builtin.c b/builtin.c index 99293b9a..b70176dc 100644 --- a/builtin.c +++ b/builtin.c @@ -3752,7 +3752,7 @@ do_bindtextdomain(int nargs) return make_string(the_result, strlen(the_result)); } -/* do_div --- do integer division, return quotient and remainder in dest array */ +/* do_intdiv --- do integer division, return quotient and remainder in dest array */ /* * We define the semantics as: @@ -3763,7 +3763,7 @@ do_bindtextdomain(int nargs) */ NODE * -do_div(int nargs) +do_intdiv(int nargs) { NODE *numerator, *denominator, *result; double num, denom, quotient, remainder; @@ -3771,7 +3771,7 @@ do_div(int nargs) result = POP_PARAM(); if (result->type != Node_var_array) - fatal(_("div: third argument is not an array")); + fatal(_("intdiv: third argument is not an array")); assoc_clear(result); denominator = POP_SCALAR(); @@ -3779,9 +3779,9 @@ do_div(int nargs) if (do_lint) { if ((numerator->flags & (NUMCUR|NUMBER)) == 0) - lintwarn(_("div: received non-numeric first argument")); + lintwarn(_("intdiv: received non-numeric first argument")); if ((denominator->flags & (NUMCUR|NUMBER)) == 0) - lintwarn(_("div: received non-numeric second argument")); + lintwarn(_("intdiv: received non-numeric second argument")); } (void) force_number(numerator); @@ -3790,7 +3790,7 @@ do_div(int nargs) denom = double_to_int(get_number_d(denominator)); if (denom == 0.0) - fatal(_("div: division by zero attempted")); + fatal(_("intdiv: division by zero attempted")); quotient = double_to_int(num / denom); /* diff --git a/doc/ChangeLog b/doc/ChangeLog index e41bf158..0e88c869 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2015-04-02 Arnold D. Robbins + + * gawktexi.in, gawk.1, awkcard.in: Name change: div() --> intdiv(). + 2015-03-31 Arnold D. Robbins * gawktexi.in: Update discussion of calling built-in functions diff --git a/doc/awkcard.in b/doc/awkcard.in index 556bdc1e..2e455b2d 100644 --- a/doc/awkcard.in +++ b/doc/awkcard.in @@ -1609,11 +1609,11 @@ expand; l lw(2i). \*(CD\*(FCatan2(\*(FIy\*(FC, \*(FIx\*(FC)\*(FR The arctangent of \*(FIy/x\fP in radians. \*(FCcos(\*(FIexpr\*(FC)\*(FR The cosine of \*(FIexpr\fP, which is in radians. -\*(CB\*(FCdiv(\*(FIn\*(FR\*(FC,\*(FI d\*(FR\*(FC,\*(FI res\*(FR\*(FC)\*(FR T{ -Return the result of integer division in \*(FIres\*(FR.\*(CD -T} \*(FCexp(\*(FIexpr\*(FC)\*(FR The exponential function (\*(FIe \*(FC^ \*(FIx\*(FR). \*(FCint(\*(FIexpr\*(FC)\*(FR Truncate to integer. +\*(CB\*(FCintdiv(\*(FIn\*(FR\*(FC,\*(FI d\*(FR\*(FC,\*(FI res\*(FR\*(FC)\*(FR T{ +Return the result of integer division in \*(FIres\*(FR.\*(CD +T} \*(FClog(\*(FIexpr\*(FC)\*(FR The natural logarithm function (base \*(FIe\^\*(FR). \*(FCrand()\fP A random number \*(FIN\fP such that 0 \(<= \*(FIN\fP < 1. \*(FCsin(\*(FIexpr\*(FC)\*(FR The sine of \*(FIexpr\fP, which is in radians. diff --git a/doc/gawk.1 b/doc/gawk.1 index 45a4c9f2..cbc15d15 100644 --- a/doc/gawk.1 +++ b/doc/gawk.1 @@ -13,7 +13,7 @@ . if \w'\(rq' .ds rq "\(rq . \} .\} -.TH GAWK 1 "Mar 24 2015" "Free Software Foundation" "Utility Commands" +.TH GAWK 1 "Apr 02 2015" "Free Software Foundation" "Utility Commands" .SH NAME gawk \- pattern scanning and processing language .SH SYNOPSIS @@ -2680,7 +2680,13 @@ Return the cosine of .IR expr , which is in radians. .TP -.BI div( num ", " denom ", " result ) +.BI exp( expr ) +The exponential function. +.TP +.BI int( expr ) +Truncate to integer. +.TP +.BI intdiv( num ", " denom ", " result ) Truncate .I num and @@ -2697,12 +2703,6 @@ This is a extension, primarily of value when working with arbitrarily large integers. .TP -.BI exp( expr ) -The exponential function. -.TP -.BI int( expr ) -Truncate to integer. -.TP .BI log( expr ) The natural logarithm function. .TP diff --git a/doc/gawk.info b/doc/gawk.info index 24a4a638..685df45b 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -12031,7 +12031,17 @@ brackets ([ ]): `cos(X)' Return the cosine of X, with X in radians. -`div(NUMERATOR, DENOMINATOR, RESULT)' +`exp(X)' + Return the exponential of X (`e ^ X') or report an error if X is + out of range. The range of values X can have depends on your + machine's floating-point representation. + +`int(X)' + Return the nearest integer to X, located between X and zero and + truncated toward zero. For example, `int(3)' is 3, `int(3.9)' is + 3, `int(-3.9)' is -3, and `int(-3)' is -3 as well. + +`intdiv(NUMERATOR, DENOMINATOR, RESULT)' Perform integer division, similar to the standard C function of the same name. First, truncate `numerator' and `denominator' towards zero, creating integer values. Clear the `result' array, and then @@ -12046,16 +12056,6 @@ brackets ([ ]): This function is a `gawk' extension. It is not available in compatibility mode (*note Options::). -`exp(X)' - Return the exponential of X (`e ^ X') or report an error if X is - out of range. The range of values X can have depends on your - machine's floating-point representation. - -`int(X)' - Return the nearest integer to X, located between X and zero and - truncated toward zero. For example, `int(3)' is 3, `int(3.9)' is - 3, `int(-3.9)' is -3, and `int(-3)' is -3 as well. - `log(X)' Return the natural logarithm of X, if X is positive; otherwise, return `NaN' ("not a number") on IEEE 754 systems. Additionally, @@ -22618,14 +22618,15 @@ the following: `%', the result is typically an arbitrary precision floating point value (unless the denominator evenly divides into the numerator). In order to do integer division or remainder with arbitrary precision -integers, use the built-in `div()' function (*note Numeric Functions::). +integers, use the built-in `intdiv()' function (*note Numeric +Functions::). - You can simulate the `div()' function in standard `awk' using this -user-defined function: + You can simulate the `intdiv()' function in standard `awk' using +this user-defined function: - # div --- do integer division + # intdiv --- do integer division - function div(numerator, denominator, result) + function intdiv(numerator, denominator, result) { split("", result) @@ -22638,8 +22639,8 @@ user-defined function: } The following example program, contributed by Katie Wasserman, uses -`div()' to compute the digits of pi to as many places as you choose to -set: +`intdiv()' to compute the digits of pi to as many places as you choose +to set: # pi.awk --- compute the digits of pi @@ -22650,7 +22651,7 @@ set: for (m = digits * 4; m > 0; --m) { d = m * 2 + 1 x = pi * m - div(x, d, result) + intdiv(x, d, result) pi = result["quotient"] pi = pi + two } @@ -26752,8 +26753,8 @@ the current version of `gawk'. - The `bindtextdomain()', `dcgettext()', and `dcngettext()' functions for internationalization (*note Programmer i18n::) - - The `div()' function for doing integer division and remainder - (*note Numeric Functions::) + - The `intdiv()' function for doing integer division and + remainder (*note Numeric Functions::) * Changes and/or additions in the command-line options: @@ -27213,7 +27214,7 @@ in POSIX `awk', in the order they were added to `gawk'. * The `igawk' program and its manual page are no longer installed when `gawk' is built. *Note Igawk Program::. - * The `div()' function. *Note Numeric Functions::. + * The `intdiv()' function. *Note Numeric Functions::. * The maximum number of hexdecimal digits in `\x' escapes is now two. *Note Escape Sequences::. @@ -32941,7 +32942,6 @@ Index * display debugger command: Viewing And Changing Data. (line 8) * display debugger options: Debugger Info. (line 57) -* div: Numeric Functions. (line 18) * division: Arithmetic Ops. (line 44) * do-while statement: Do Statement. (line 6) * do-while statement, use of regexps in: Regexp Usage. (line 19) @@ -33061,10 +33061,10 @@ Index * exit status, of VMS: VMS Running. (line 28) * exit the debugger: Miscellaneous Debugger Commands. (line 99) -* exp: Numeric Functions. (line 33) +* exp: Numeric Functions. (line 18) * expand utility: Very Simple. (line 73) * Expat XML parser library: gawkextlib. (line 37) -* exponent: Numeric Functions. (line 33) +* exponent: Numeric Functions. (line 18) * expressions: Expressions. (line 6) * expressions, as patterns: Expression Patterns. (line 6) * expressions, assignment: Assignment Ops. (line 6) @@ -33608,8 +33608,9 @@ Index * installation, VMS: VMS Installation. (line 6) * installing gawk: Installation. (line 6) * instruction tracing, in debugger: Debugger Info. (line 90) -* int: Numeric Functions. (line 38) +* int: Numeric Functions. (line 23) * INT signal (MS-Windows): Profiling. (line 213) +* intdiv: Numeric Functions. (line 28) * integer array indices: Numeric Array Subscripts. (line 31) * integers, arbitrary precision: Arbitrary Precision Integers. @@ -34349,7 +34350,7 @@ Index * Robbins, Miriam <2>: Getline/Pipe. (line 39) * Robbins, Miriam: Acknowledgments. (line 94) * Rommel, Kai Uwe: Contributors. (line 42) -* round to nearest integer: Numeric Functions. (line 38) +* round to nearest integer: Numeric Functions. (line 23) * round() user-defined function: Round Function. (line 16) * rounding numbers: Round Function. (line 6) * ROUNDMODE variable: User-modified. (line 127) @@ -35126,333 +35127,333 @@ Node: Functions504950 Node: Built-in505989 Node: Calling Built-in507067 Node: Numeric Functions509062 -Ref: Numeric Functions-Footnote-1513892 -Ref: Numeric Functions-Footnote-2514249 -Ref: Numeric Functions-Footnote-3514297 -Node: String Functions514569 -Ref: String Functions-Footnote-1538070 -Ref: String Functions-Footnote-2538199 -Ref: String Functions-Footnote-3538447 -Node: Gory Details538534 -Ref: table-sub-escapes540315 -Ref: table-sub-proposed541830 -Ref: table-posix-sub543192 -Ref: table-gensub-escapes544729 -Ref: Gory Details-Footnote-1545562 -Node: I/O Functions545713 -Ref: I/O Functions-Footnote-1552949 -Node: Time Functions553096 -Ref: Time Functions-Footnote-1563605 -Ref: Time Functions-Footnote-2563673 -Ref: Time Functions-Footnote-3563831 -Ref: Time Functions-Footnote-4563942 -Ref: Time Functions-Footnote-5564054 -Ref: Time Functions-Footnote-6564281 -Node: Bitwise Functions564547 -Ref: table-bitwise-ops565109 -Ref: Bitwise Functions-Footnote-1569437 -Node: Type Functions569609 -Node: I18N Functions570761 -Node: User-defined572408 -Node: Definition Syntax573213 -Ref: Definition Syntax-Footnote-1578872 -Node: Function Example578943 -Ref: Function Example-Footnote-1581864 -Node: Function Caveats581886 -Node: Calling A Function582404 -Node: Variable Scope583362 -Node: Pass By Value/Reference586355 -Node: Return Statement589852 -Node: Dynamic Typing592831 -Node: Indirect Calls593760 -Ref: Indirect Calls-Footnote-1604003 -Node: Functions Summary604131 -Node: Library Functions606833 -Ref: Library Functions-Footnote-1610441 -Ref: Library Functions-Footnote-2610584 -Node: Library Names610755 -Ref: Library Names-Footnote-1614213 -Ref: Library Names-Footnote-2614436 -Node: General Functions614522 -Node: Strtonum Function615625 -Node: Assert Function618647 -Node: Round Function621971 -Node: Cliff Random Function623512 -Node: Ordinal Functions624528 -Ref: Ordinal Functions-Footnote-1627591 -Ref: Ordinal Functions-Footnote-2627843 -Node: Join Function628054 -Ref: Join Function-Footnote-1629824 -Node: Getlocaltime Function630024 -Node: Readfile Function633768 -Node: Shell Quoting635740 -Node: Data File Management637141 -Node: Filetrans Function637773 -Node: Rewind Function641869 -Node: File Checking643255 -Ref: File Checking-Footnote-1644588 -Node: Empty Files644789 -Node: Ignoring Assigns646768 -Node: Getopt Function648318 -Ref: Getopt Function-Footnote-1659782 -Node: Passwd Functions659982 -Ref: Passwd Functions-Footnote-1668822 -Node: Group Functions668910 -Ref: Group Functions-Footnote-1676807 -Node: Walking Arrays677012 -Node: Library Functions Summary680018 -Node: Library Exercises681420 -Node: Sample Programs682700 -Node: Running Examples683470 -Node: Clones684198 -Node: Cut Program685422 -Node: Egrep Program695142 -Ref: Egrep Program-Footnote-1702645 -Node: Id Program702755 -Node: Split Program706431 -Ref: Split Program-Footnote-1709885 -Node: Tee Program710013 -Node: Uniq Program712802 -Node: Wc Program720221 -Ref: Wc Program-Footnote-1724471 -Node: Miscellaneous Programs724565 -Node: Dupword Program725778 -Node: Alarm Program727809 -Node: Translate Program732614 -Ref: Translate Program-Footnote-1737177 -Node: Labels Program737447 -Ref: Labels Program-Footnote-1740798 -Node: Word Sorting740882 -Node: History Sorting744952 -Node: Extract Program746787 -Node: Simple Sed754311 -Node: Igawk Program757381 -Ref: Igawk Program-Footnote-1771707 -Ref: Igawk Program-Footnote-2771908 -Ref: Igawk Program-Footnote-3772030 -Node: Anagram Program772145 -Node: Signature Program775206 -Node: Programs Summary776453 -Node: Programs Exercises777674 -Ref: Programs Exercises-Footnote-1781805 -Node: Advanced Features781896 -Node: Nondecimal Data783878 -Node: Array Sorting785468 -Node: Controlling Array Traversal786168 -Ref: Controlling Array Traversal-Footnote-1794534 -Node: Array Sorting Functions794652 -Ref: Array Sorting Functions-Footnote-1798538 -Node: Two-way I/O798734 -Ref: Two-way I/O-Footnote-1803679 -Ref: Two-way I/O-Footnote-2803865 -Node: TCP/IP Networking803947 -Node: Profiling806819 -Node: Advanced Features Summary815090 -Node: Internationalization817023 -Node: I18N and L10N818503 -Node: Explaining gettext819189 -Ref: Explaining gettext-Footnote-1824214 -Ref: Explaining gettext-Footnote-2824398 -Node: Programmer i18n824563 -Ref: Programmer i18n-Footnote-1829439 -Node: Translator i18n829488 -Node: String Extraction830282 -Ref: String Extraction-Footnote-1831413 -Node: Printf Ordering831499 -Ref: Printf Ordering-Footnote-1834285 -Node: I18N Portability834349 -Ref: I18N Portability-Footnote-1836805 -Node: I18N Example836868 -Ref: I18N Example-Footnote-1839671 -Node: Gawk I18N839743 -Node: I18N Summary840387 -Node: Debugger841727 -Node: Debugging842749 -Node: Debugging Concepts843190 -Node: Debugging Terms845000 -Node: Awk Debugging847572 -Node: Sample Debugging Session848478 -Node: Debugger Invocation849012 -Node: Finding The Bug850397 -Node: List of Debugger Commands856876 -Node: Breakpoint Control858208 -Node: Debugger Execution Control861885 -Node: Viewing And Changing Data865244 -Node: Execution Stack868620 -Node: Debugger Info870255 -Node: Miscellaneous Debugger Commands874300 -Node: Readline Support879301 -Node: Limitations880195 -Node: Debugging Summary882310 -Node: Arbitrary Precision Arithmetic883484 -Node: Computer Arithmetic884900 -Ref: table-numeric-ranges888477 -Ref: Computer Arithmetic-Footnote-1889001 -Node: Math Definitions889058 -Ref: table-ieee-formats892353 -Ref: Math Definitions-Footnote-1892957 -Node: MPFR features893062 -Node: FP Math Caution894733 -Ref: FP Math Caution-Footnote-1895783 -Node: Inexactness of computations896152 -Node: Inexact representation897111 -Node: Comparing FP Values898469 -Node: Errors accumulate899551 -Node: Getting Accuracy900983 -Node: Try To Round903687 -Node: Setting precision904586 -Ref: table-predefined-precision-strings905270 -Node: Setting the rounding mode907099 -Ref: table-gawk-rounding-modes907463 -Ref: Setting the rounding mode-Footnote-1910915 -Node: Arbitrary Precision Integers911094 -Ref: Arbitrary Precision Integers-Footnote-1915992 -Node: POSIX Floating Point Problems916141 -Ref: POSIX Floating Point Problems-Footnote-1920020 -Node: Floating point summary920058 -Node: Dynamic Extensions922245 -Node: Extension Intro923797 -Node: Plugin License925062 -Node: Extension Mechanism Outline925859 -Ref: figure-load-extension926287 -Ref: figure-register-new-function927767 -Ref: figure-call-new-function928771 -Node: Extension API Description930758 -Node: Extension API Functions Introduction932292 -Node: General Data Types937161 -Ref: General Data Types-Footnote-1943061 -Node: Memory Allocation Functions943360 -Ref: Memory Allocation Functions-Footnote-1946199 -Node: Constructor Functions946298 -Node: Registration Functions948037 -Node: Extension Functions948722 -Node: Exit Callback Functions951019 -Node: Extension Version String952267 -Node: Input Parsers952930 -Node: Output Wrappers962805 -Node: Two-way processors967318 -Node: Printing Messages969581 -Ref: Printing Messages-Footnote-1970657 -Node: Updating `ERRNO'970809 -Node: Requesting Values971549 -Ref: table-value-types-returned972276 -Node: Accessing Parameters973233 -Node: Symbol Table Access974467 -Node: Symbol table by name974981 -Node: Symbol table by cookie977001 -Ref: Symbol table by cookie-Footnote-1981146 -Node: Cached values981209 -Ref: Cached values-Footnote-1984705 -Node: Array Manipulation984796 -Ref: Array Manipulation-Footnote-1985886 -Node: Array Data Types985923 -Ref: Array Data Types-Footnote-1988578 -Node: Array Functions988670 -Node: Flattening Arrays992529 -Node: Creating Arrays999431 -Node: Redirection API1004202 -Node: Extension API Variables1007027 -Node: Extension Versioning1007660 -Node: Extension API Informational Variables1009551 -Node: Extension API Boilerplate1010616 -Node: Finding Extensions1014425 -Node: Extension Example1014985 -Node: Internal File Description1015757 -Node: Internal File Ops1019824 -Ref: Internal File Ops-Footnote-11031575 -Node: Using Internal File Ops1031715 -Ref: Using Internal File Ops-Footnote-11034098 -Node: Extension Samples1034371 -Node: Extension Sample File Functions1035899 -Node: Extension Sample Fnmatch1043580 -Node: Extension Sample Fork1045068 -Node: Extension Sample Inplace1046283 -Node: Extension Sample Ord1048369 -Node: Extension Sample Readdir1049205 -Ref: table-readdir-file-types1050082 -Node: Extension Sample Revout1050893 -Node: Extension Sample Rev2way1051482 -Node: Extension Sample Read write array1052222 -Node: Extension Sample Readfile1054162 -Node: Extension Sample Time1055257 -Node: Extension Sample API Tests1056605 -Node: gawkextlib1057096 -Node: Extension summary1059797 -Node: Extension Exercises1063486 -Node: Language History1064982 -Node: V7/SVR3.11066638 -Node: SVR41068791 -Node: POSIX1070225 -Node: BTL1071606 -Node: POSIX/GNU1072337 -Node: Feature History1078173 -Node: Common Extensions1091967 -Node: Ranges and Locales1093339 -Ref: Ranges and Locales-Footnote-11097958 -Ref: Ranges and Locales-Footnote-21097985 -Ref: Ranges and Locales-Footnote-31098220 -Node: Contributors1098441 -Node: History summary1103981 -Node: Installation1105360 -Node: Gawk Distribution1106306 -Node: Getting1106790 -Node: Extracting1107613 -Node: Distribution contents1109250 -Node: Unix Installation1115352 -Node: Quick Installation1116035 -Node: Shell Startup Files1118446 -Node: Additional Configuration Options1119525 -Node: Configuration Philosophy1121329 -Node: Non-Unix Installation1123698 -Node: PC Installation1124156 -Node: PC Binary Installation1125476 -Node: PC Compiling1127324 -Ref: PC Compiling-Footnote-11130345 -Node: PC Testing1130454 -Node: PC Using1131630 -Node: Cygwin1135745 -Node: MSYS1136515 -Node: VMS Installation1137016 -Node: VMS Compilation1137808 -Ref: VMS Compilation-Footnote-11139037 -Node: VMS Dynamic Extensions1139095 -Node: VMS Installation Details1140779 -Node: VMS Running1143030 -Node: VMS GNV1145870 -Node: VMS Old Gawk1146605 -Node: Bugs1147075 -Node: Other Versions1150964 -Node: Installation summary1157398 -Node: Notes1158457 -Node: Compatibility Mode1159322 -Node: Additions1160104 -Node: Accessing The Source1161029 -Node: Adding Code1162464 -Node: New Ports1168621 -Node: Derived Files1173103 -Ref: Derived Files-Footnote-11178578 -Ref: Derived Files-Footnote-21178612 -Ref: Derived Files-Footnote-31179208 -Node: Future Extensions1179322 -Node: Implementation Limitations1179928 -Node: Extension Design1181176 -Node: Old Extension Problems1182330 -Ref: Old Extension Problems-Footnote-11183847 -Node: Extension New Mechanism Goals1183904 -Ref: Extension New Mechanism Goals-Footnote-11187264 -Node: Extension Other Design Decisions1187453 -Node: Extension Future Growth1189561 -Node: Old Extension Mechanism1190397 -Node: Notes summary1192159 -Node: Basic Concepts1193345 -Node: Basic High Level1194026 -Ref: figure-general-flow1194298 -Ref: figure-process-flow1194897 -Ref: Basic High Level-Footnote-11198126 -Node: Basic Data Typing1198311 -Node: Glossary1201639 -Node: Copying1233568 -Node: GNU Free Documentation License1271124 -Node: Index1296260 +Ref: Numeric Functions-Footnote-1513895 +Ref: Numeric Functions-Footnote-2514252 +Ref: Numeric Functions-Footnote-3514300 +Node: String Functions514572 +Ref: String Functions-Footnote-1538073 +Ref: String Functions-Footnote-2538202 +Ref: String Functions-Footnote-3538450 +Node: Gory Details538537 +Ref: table-sub-escapes540318 +Ref: table-sub-proposed541833 +Ref: table-posix-sub543195 +Ref: table-gensub-escapes544732 +Ref: Gory Details-Footnote-1545565 +Node: I/O Functions545716 +Ref: I/O Functions-Footnote-1552952 +Node: Time Functions553099 +Ref: Time Functions-Footnote-1563608 +Ref: Time Functions-Footnote-2563676 +Ref: Time Functions-Footnote-3563834 +Ref: Time Functions-Footnote-4563945 +Ref: Time Functions-Footnote-5564057 +Ref: Time Functions-Footnote-6564284 +Node: Bitwise Functions564550 +Ref: table-bitwise-ops565112 +Ref: Bitwise Functions-Footnote-1569440 +Node: Type Functions569612 +Node: I18N Functions570764 +Node: User-defined572411 +Node: Definition Syntax573216 +Ref: Definition Syntax-Footnote-1578875 +Node: Function Example578946 +Ref: Function Example-Footnote-1581867 +Node: Function Caveats581889 +Node: Calling A Function582407 +Node: Variable Scope583365 +Node: Pass By Value/Reference586358 +Node: Return Statement589855 +Node: Dynamic Typing592834 +Node: Indirect Calls593763 +Ref: Indirect Calls-Footnote-1604006 +Node: Functions Summary604134 +Node: Library Functions606836 +Ref: Library Functions-Footnote-1610444 +Ref: Library Functions-Footnote-2610587 +Node: Library Names610758 +Ref: Library Names-Footnote-1614216 +Ref: Library Names-Footnote-2614439 +Node: General Functions614525 +Node: Strtonum Function615628 +Node: Assert Function618650 +Node: Round Function621974 +Node: Cliff Random Function623515 +Node: Ordinal Functions624531 +Ref: Ordinal Functions-Footnote-1627594 +Ref: Ordinal Functions-Footnote-2627846 +Node: Join Function628057 +Ref: Join Function-Footnote-1629827 +Node: Getlocaltime Function630027 +Node: Readfile Function633771 +Node: Shell Quoting635743 +Node: Data File Management637144 +Node: Filetrans Function637776 +Node: Rewind Function641872 +Node: File Checking643258 +Ref: File Checking-Footnote-1644591 +Node: Empty Files644792 +Node: Ignoring Assigns646771 +Node: Getopt Function648321 +Ref: Getopt Function-Footnote-1659785 +Node: Passwd Functions659985 +Ref: Passwd Functions-Footnote-1668825 +Node: Group Functions668913 +Ref: Group Functions-Footnote-1676810 +Node: Walking Arrays677015 +Node: Library Functions Summary680021 +Node: Library Exercises681423 +Node: Sample Programs682703 +Node: Running Examples683473 +Node: Clones684201 +Node: Cut Program685425 +Node: Egrep Program695145 +Ref: Egrep Program-Footnote-1702648 +Node: Id Program702758 +Node: Split Program706434 +Ref: Split Program-Footnote-1709888 +Node: Tee Program710016 +Node: Uniq Program712805 +Node: Wc Program720224 +Ref: Wc Program-Footnote-1724474 +Node: Miscellaneous Programs724568 +Node: Dupword Program725781 +Node: Alarm Program727812 +Node: Translate Program732617 +Ref: Translate Program-Footnote-1737180 +Node: Labels Program737450 +Ref: Labels Program-Footnote-1740801 +Node: Word Sorting740885 +Node: History Sorting744955 +Node: Extract Program746790 +Node: Simple Sed754314 +Node: Igawk Program757384 +Ref: Igawk Program-Footnote-1771710 +Ref: Igawk Program-Footnote-2771911 +Ref: Igawk Program-Footnote-3772033 +Node: Anagram Program772148 +Node: Signature Program775209 +Node: Programs Summary776456 +Node: Programs Exercises777677 +Ref: Programs Exercises-Footnote-1781808 +Node: Advanced Features781899 +Node: Nondecimal Data783881 +Node: Array Sorting785471 +Node: Controlling Array Traversal786171 +Ref: Controlling Array Traversal-Footnote-1794537 +Node: Array Sorting Functions794655 +Ref: Array Sorting Functions-Footnote-1798541 +Node: Two-way I/O798737 +Ref: Two-way I/O-Footnote-1803682 +Ref: Two-way I/O-Footnote-2803868 +Node: TCP/IP Networking803950 +Node: Profiling806822 +Node: Advanced Features Summary815093 +Node: Internationalization817026 +Node: I18N and L10N818506 +Node: Explaining gettext819192 +Ref: Explaining gettext-Footnote-1824217 +Ref: Explaining gettext-Footnote-2824401 +Node: Programmer i18n824566 +Ref: Programmer i18n-Footnote-1829442 +Node: Translator i18n829491 +Node: String Extraction830285 +Ref: String Extraction-Footnote-1831416 +Node: Printf Ordering831502 +Ref: Printf Ordering-Footnote-1834288 +Node: I18N Portability834352 +Ref: I18N Portability-Footnote-1836808 +Node: I18N Example836871 +Ref: I18N Example-Footnote-1839674 +Node: Gawk I18N839746 +Node: I18N Summary840390 +Node: Debugger841730 +Node: Debugging842752 +Node: Debugging Concepts843193 +Node: Debugging Terms845003 +Node: Awk Debugging847575 +Node: Sample Debugging Session848481 +Node: Debugger Invocation849015 +Node: Finding The Bug850400 +Node: List of Debugger Commands856879 +Node: Breakpoint Control858211 +Node: Debugger Execution Control861888 +Node: Viewing And Changing Data865247 +Node: Execution Stack868623 +Node: Debugger Info870258 +Node: Miscellaneous Debugger Commands874303 +Node: Readline Support879304 +Node: Limitations880198 +Node: Debugging Summary882313 +Node: Arbitrary Precision Arithmetic883487 +Node: Computer Arithmetic884903 +Ref: table-numeric-ranges888480 +Ref: Computer Arithmetic-Footnote-1889004 +Node: Math Definitions889061 +Ref: table-ieee-formats892356 +Ref: Math Definitions-Footnote-1892960 +Node: MPFR features893065 +Node: FP Math Caution894736 +Ref: FP Math Caution-Footnote-1895786 +Node: Inexactness of computations896155 +Node: Inexact representation897114 +Node: Comparing FP Values898472 +Node: Errors accumulate899554 +Node: Getting Accuracy900986 +Node: Try To Round903690 +Node: Setting precision904589 +Ref: table-predefined-precision-strings905273 +Node: Setting the rounding mode907102 +Ref: table-gawk-rounding-modes907466 +Ref: Setting the rounding mode-Footnote-1910918 +Node: Arbitrary Precision Integers911097 +Ref: Arbitrary Precision Integers-Footnote-1916013 +Node: POSIX Floating Point Problems916162 +Ref: POSIX Floating Point Problems-Footnote-1920041 +Node: Floating point summary920079 +Node: Dynamic Extensions922266 +Node: Extension Intro923818 +Node: Plugin License925083 +Node: Extension Mechanism Outline925880 +Ref: figure-load-extension926308 +Ref: figure-register-new-function927788 +Ref: figure-call-new-function928792 +Node: Extension API Description930779 +Node: Extension API Functions Introduction932313 +Node: General Data Types937182 +Ref: General Data Types-Footnote-1943082 +Node: Memory Allocation Functions943381 +Ref: Memory Allocation Functions-Footnote-1946220 +Node: Constructor Functions946319 +Node: Registration Functions948058 +Node: Extension Functions948743 +Node: Exit Callback Functions951040 +Node: Extension Version String952288 +Node: Input Parsers952951 +Node: Output Wrappers962826 +Node: Two-way processors967339 +Node: Printing Messages969602 +Ref: Printing Messages-Footnote-1970678 +Node: Updating `ERRNO'970830 +Node: Requesting Values971570 +Ref: table-value-types-returned972297 +Node: Accessing Parameters973254 +Node: Symbol Table Access974488 +Node: Symbol table by name975002 +Node: Symbol table by cookie977022 +Ref: Symbol table by cookie-Footnote-1981167 +Node: Cached values981230 +Ref: Cached values-Footnote-1984726 +Node: Array Manipulation984817 +Ref: Array Manipulation-Footnote-1985907 +Node: Array Data Types985944 +Ref: Array Data Types-Footnote-1988599 +Node: Array Functions988691 +Node: Flattening Arrays992550 +Node: Creating Arrays999452 +Node: Redirection API1004223 +Node: Extension API Variables1007048 +Node: Extension Versioning1007681 +Node: Extension API Informational Variables1009572 +Node: Extension API Boilerplate1010637 +Node: Finding Extensions1014446 +Node: Extension Example1015006 +Node: Internal File Description1015778 +Node: Internal File Ops1019845 +Ref: Internal File Ops-Footnote-11031596 +Node: Using Internal File Ops1031736 +Ref: Using Internal File Ops-Footnote-11034119 +Node: Extension Samples1034392 +Node: Extension Sample File Functions1035920 +Node: Extension Sample Fnmatch1043601 +Node: Extension Sample Fork1045089 +Node: Extension Sample Inplace1046304 +Node: Extension Sample Ord1048390 +Node: Extension Sample Readdir1049226 +Ref: table-readdir-file-types1050103 +Node: Extension Sample Revout1050914 +Node: Extension Sample Rev2way1051503 +Node: Extension Sample Read write array1052243 +Node: Extension Sample Readfile1054183 +Node: Extension Sample Time1055278 +Node: Extension Sample API Tests1056626 +Node: gawkextlib1057117 +Node: Extension summary1059818 +Node: Extension Exercises1063507 +Node: Language History1065003 +Node: V7/SVR3.11066659 +Node: SVR41068812 +Node: POSIX1070246 +Node: BTL1071627 +Node: POSIX/GNU1072358 +Node: Feature History1078197 +Node: Common Extensions1091994 +Node: Ranges and Locales1093366 +Ref: Ranges and Locales-Footnote-11097985 +Ref: Ranges and Locales-Footnote-21098012 +Ref: Ranges and Locales-Footnote-31098247 +Node: Contributors1098468 +Node: History summary1104008 +Node: Installation1105387 +Node: Gawk Distribution1106333 +Node: Getting1106817 +Node: Extracting1107640 +Node: Distribution contents1109277 +Node: Unix Installation1115379 +Node: Quick Installation1116062 +Node: Shell Startup Files1118473 +Node: Additional Configuration Options1119552 +Node: Configuration Philosophy1121356 +Node: Non-Unix Installation1123725 +Node: PC Installation1124183 +Node: PC Binary Installation1125503 +Node: PC Compiling1127351 +Ref: PC Compiling-Footnote-11130372 +Node: PC Testing1130481 +Node: PC Using1131657 +Node: Cygwin1135772 +Node: MSYS1136542 +Node: VMS Installation1137043 +Node: VMS Compilation1137835 +Ref: VMS Compilation-Footnote-11139064 +Node: VMS Dynamic Extensions1139122 +Node: VMS Installation Details1140806 +Node: VMS Running1143057 +Node: VMS GNV1145897 +Node: VMS Old Gawk1146632 +Node: Bugs1147102 +Node: Other Versions1150991 +Node: Installation summary1157425 +Node: Notes1158484 +Node: Compatibility Mode1159349 +Node: Additions1160131 +Node: Accessing The Source1161056 +Node: Adding Code1162491 +Node: New Ports1168648 +Node: Derived Files1173130 +Ref: Derived Files-Footnote-11178605 +Ref: Derived Files-Footnote-21178639 +Ref: Derived Files-Footnote-31179235 +Node: Future Extensions1179349 +Node: Implementation Limitations1179955 +Node: Extension Design1181203 +Node: Old Extension Problems1182357 +Ref: Old Extension Problems-Footnote-11183874 +Node: Extension New Mechanism Goals1183931 +Ref: Extension New Mechanism Goals-Footnote-11187291 +Node: Extension Other Design Decisions1187480 +Node: Extension Future Growth1189588 +Node: Old Extension Mechanism1190424 +Node: Notes summary1192186 +Node: Basic Concepts1193372 +Node: Basic High Level1194053 +Ref: figure-general-flow1194325 +Ref: figure-process-flow1194924 +Ref: Basic High Level-Footnote-11198153 +Node: Basic Data Typing1198338 +Node: Glossary1201666 +Node: Copying1233595 +Node: GNU Free Documentation License1271151 +Node: Index1296287  End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index f710d725..ca378cca 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -17089,23 +17089,6 @@ You can use @samp{pi = atan2(0, -1)} to retrieve the value of @cindex cosine Return the cosine of @var{x}, with @var{x} in radians. -@item @code{div(@var{numerator}, @var{denominator}, @var{result})} -@cindexawkfunc{div} -@cindex div -Perform integer division, similar to the standard C function of the -same name. First, truncate @code{numerator} and @code{denominator} -towards zero, creating integer values. Clear the @code{result} -array, and then set @code{result["quotient"]} to the result of -@samp{numerator / denominator}, truncated towards zero to an integer, -and set @code{result["remainder"]} to the result of @samp{numerator % -denominator}, truncated towards zero to an integer. This function is -primarily intended for use with arbitrary length integers; it avoids -creating MPFR arbitrary precision floating-point values (@pxref{Arbitrary -Precision Integers}). - -This function is a @code{gawk} extension. It is not available in -compatibility mode (@pxref{Options}). - @item @code{exp(@var{x})} @cindexawkfunc{exp} @cindex exponent @@ -17121,6 +17104,23 @@ truncated toward zero. For example, @code{int(3)} is 3, @code{int(3.9)} is 3, @code{int(-3.9)} is @minus{}3, and @code{int(-3)} is @minus{}3 as well. +@item @code{intdiv(@var{numerator}, @var{denominator}, @var{result})} +@cindexawkfunc{intdiv} +@cindex intdiv +Perform integer division, similar to the standard C function of the +same name. First, truncate @code{numerator} and @code{denominator} +towards zero, creating integer values. Clear the @code{result} +array, and then set @code{result["quotient"]} to the result of +@samp{numerator / denominator}, truncated towards zero to an integer, +and set @code{result["remainder"]} to the result of @samp{numerator % +denominator}, truncated towards zero to an integer. This function is +primarily intended for use with arbitrary length integers; it avoids +creating MPFR arbitrary precision floating-point values (@pxref{Arbitrary +Precision Integers}). + +This function is a @code{gawk} extension. It is not available in +compatibility mode (@pxref{Options}). + @item @code{log(@var{x})} @cindexawkfunc{log} @cindex logarithm @@ -31114,27 +31114,30 @@ When dividing two arbitrary precision integers with either precision floating point value (unless the denominator evenly divides into the numerator). In order to do integer division or remainder with arbitrary precision integers, use the built-in -@code{div()} function (@pxref{Numeric Functions}). +@code{intdiv()} function (@pxref{Numeric Functions}). -You can simulate the @code{div()} function in standard @command{awk} +You can simulate the @code{intdiv()} function in standard @command{awk} using this user-defined function: @example -@c file eg/lib/div.awk -# div --- do integer division +@c file eg/lib/intdiv.awk +# intdiv --- do integer division @c endfile @ignore -@c file eg/lib/div.awk +@c file eg/lib/intdiv.awk # # Arnold Robbins, arnold@@skeeve.com, Public Domain # July, 2014 +# +# Name changed from div() to intdiv() +# April, 2015 @c endfile @end ignore -@c file eg/lib/div.awk -function div(numerator, denominator, result) +@c file eg/lib/intdiv.awk +function intdiv(numerator, denominator, result) @{ split("", result) @@ -31149,7 +31152,7 @@ function div(numerator, denominator, result) @end example The following example program, contributed by Katie Wasserman, -uses @code{div()} to +uses @code{intdiv()} to compute the digits of @value{PI} to as many places as you choose to set: @@ -31174,7 +31177,7 @@ BEGIN @{ for (m = digits * 4; m > 0; --m) @{ d = m * 2 + 1 x = pi * m - div(x, d, result) + intdiv(x, d, result) pi = result["quotient"] pi = pi + two @} @@ -36043,7 +36046,7 @@ functions for internationalization (@pxref{Programmer i18n}) @item -The @code{div()} function for doing integer +The @code{intdiv()} function for doing integer division and remainder (@pxref{Numeric Functions}) @end itemize @@ -36824,7 +36827,7 @@ installed when @command{gawk} is built. @xref{Igawk Program}. @item -The @code{div()} function. +The @code{intdiv()} function. @xref{Numeric Functions}. @item diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 4e2b67d7..4cd04763 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -16371,23 +16371,6 @@ You can use @samp{pi = atan2(0, -1)} to retrieve the value of @cindex cosine Return the cosine of @var{x}, with @var{x} in radians. -@item @code{div(@var{numerator}, @var{denominator}, @var{result})} -@cindexawkfunc{div} -@cindex div -Perform integer division, similar to the standard C function of the -same name. First, truncate @code{numerator} and @code{denominator} -towards zero, creating integer values. Clear the @code{result} -array, and then set @code{result["quotient"]} to the result of -@samp{numerator / denominator}, truncated towards zero to an integer, -and set @code{result["remainder"]} to the result of @samp{numerator % -denominator}, truncated towards zero to an integer. This function is -primarily intended for use with arbitrary length integers; it avoids -creating MPFR arbitrary precision floating-point values (@pxref{Arbitrary -Precision Integers}). - -This function is a @code{gawk} extension. It is not available in -compatibility mode (@pxref{Options}). - @item @code{exp(@var{x})} @cindexawkfunc{exp} @cindex exponent @@ -16403,6 +16386,23 @@ truncated toward zero. For example, @code{int(3)} is 3, @code{int(3.9)} is 3, @code{int(-3.9)} is @minus{}3, and @code{int(-3)} is @minus{}3 as well. +@item @code{intdiv(@var{numerator}, @var{denominator}, @var{result})} +@cindexawkfunc{intdiv} +@cindex intdiv +Perform integer division, similar to the standard C function of the +same name. First, truncate @code{numerator} and @code{denominator} +towards zero, creating integer values. Clear the @code{result} +array, and then set @code{result["quotient"]} to the result of +@samp{numerator / denominator}, truncated towards zero to an integer, +and set @code{result["remainder"]} to the result of @samp{numerator % +denominator}, truncated towards zero to an integer. This function is +primarily intended for use with arbitrary length integers; it avoids +creating MPFR arbitrary precision floating-point values (@pxref{Arbitrary +Precision Integers}). + +This function is a @code{gawk} extension. It is not available in +compatibility mode (@pxref{Options}). + @item @code{log(@var{x})} @cindexawkfunc{log} @cindex logarithm @@ -30205,27 +30205,30 @@ When dividing two arbitrary precision integers with either precision floating point value (unless the denominator evenly divides into the numerator). In order to do integer division or remainder with arbitrary precision integers, use the built-in -@code{div()} function (@pxref{Numeric Functions}). +@code{intdiv()} function (@pxref{Numeric Functions}). -You can simulate the @code{div()} function in standard @command{awk} +You can simulate the @code{intdiv()} function in standard @command{awk} using this user-defined function: @example -@c file eg/lib/div.awk -# div --- do integer division +@c file eg/lib/intdiv.awk +# intdiv --- do integer division @c endfile @ignore -@c file eg/lib/div.awk +@c file eg/lib/intdiv.awk # # Arnold Robbins, arnold@@skeeve.com, Public Domain # July, 2014 +# +# Name changed from div() to intdiv() +# April, 2015 @c endfile @end ignore -@c file eg/lib/div.awk -function div(numerator, denominator, result) +@c file eg/lib/intdiv.awk +function intdiv(numerator, denominator, result) @{ split("", result) @@ -30240,7 +30243,7 @@ function div(numerator, denominator, result) @end example The following example program, contributed by Katie Wasserman, -uses @code{div()} to +uses @code{intdiv()} to compute the digits of @value{PI} to as many places as you choose to set: @@ -30265,7 +30268,7 @@ BEGIN @{ for (m = digits * 4; m > 0; --m) @{ d = m * 2 + 1 x = pi * m - div(x, d, result) + intdiv(x, d, result) pi = result["quotient"] pi = pi + two @} @@ -35134,7 +35137,7 @@ functions for internationalization (@pxref{Programmer i18n}) @item -The @code{div()} function for doing integer +The @code{intdiv()} function for doing integer division and remainder (@pxref{Numeric Functions}) @end itemize @@ -35915,7 +35918,7 @@ installed when @command{gawk} is built. @xref{Igawk Program}. @item -The @code{div()} function. +The @code{intdiv()} function. @xref{Numeric Functions}. @item diff --git a/mpfr.c b/mpfr.c index 571b334b..080ed7fa 100644 --- a/mpfr.c +++ b/mpfr.c @@ -1186,7 +1186,7 @@ do_mpfr_srand(int nargs) return res; } -/* do_mpfr_div --- do integer division, return quotient and remainder in dest array */ +/* do_mpfr_intdiv --- do integer division, return quotient and remainder in dest array */ /* * We define the semantics as: @@ -1197,7 +1197,7 @@ do_mpfr_srand(int nargs) */ NODE * -do_mpfr_div(int nargs) +do_mpfr_intdiv(int nargs) { NODE *numerator, *denominator, *result; NODE *num, *denom; @@ -1206,7 +1206,7 @@ do_mpfr_div(int nargs) result = POP_PARAM(); if (result->type != Node_var_array) - fatal(_("div: third argument is not an array")); + fatal(_("intdiv: third argument is not an array")); assoc_clear(result); denominator = POP_SCALAR(); @@ -1214,9 +1214,9 @@ do_mpfr_div(int nargs) if (do_lint) { if ((numerator->flags & (NUMCUR|NUMBER)) == 0) - lintwarn(_("div: received non-numeric first argument")); + lintwarn(_("intdiv: received non-numeric first argument")); if ((denominator->flags & (NUMCUR|NUMBER)) == 0) - lintwarn(_("div: received non-numeric second argument")); + lintwarn(_("intdiv: received non-numeric second argument")); } (void) force_number(numerator); @@ -1250,7 +1250,7 @@ do_mpfr_div(int nargs) } if (mpz_sgn(denom->mpg_i) == 0) - fatal(_("div: division by zero attempted")); + fatal(_("intdiv: division by zero attempted")); quotient = mpg_integer(); remainder = mpg_integer(); diff --git a/test/ChangeLog b/test/ChangeLog index 0c21218e..f9e49945 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2015-04-02 Arnold D. Robbins + + * id.ok, mpfrsqrt.awk: Update after rename of div() --> intdiv(). + 2015-03-31 Arnold D. Robbins * Makefile.am (indirectbuiltin): New test. diff --git a/test/id.ok b/test/id.ok index b5baf15a..bd26b473 100644 --- a/test/id.ok +++ b/test/id.ok @@ -24,7 +24,6 @@ cos -> builtin TEXTDOMAIN -> scalar ORS -> scalar split -> builtin -div -> builtin RSTART -> scalar compl -> builtin bindtextdomain -> builtin @@ -63,6 +62,7 @@ sub -> builtin OFMT -> scalar RLENGTH -> scalar substr -> builtin +intdiv -> builtin FPAT -> scalar RS -> scalar xor -> builtin diff --git a/test/mpfrsqrt.awk b/test/mpfrsqrt.awk index 23a15c92..3fb1f5f8 100644 --- a/test/mpfrsqrt.awk +++ b/test/mpfrsqrt.awk @@ -14,7 +14,7 @@ a=11111111111111111111111111111111111111111111111111111111111 print sqrt(a^2) #print sq_root(a^2) -# ADR: Added for gawk-4.1-stable which doesn't have built-in div() function +# ADR: Added for gawk-4.1-stable which doesn't have built-in intdiv() function if (PROCINFO["version"] < "4.1.60") print sq_root2(a^2) else @@ -27,9 +27,9 @@ function sq_root(x, temp,r,z) z=0 while (abs(z-temp)>1) { z=temp - div(x,temp,r) + intdiv(x,temp,r) temp=r["quotient"] + temp - div(temp,2,r) + intdiv(temp,2,r) temp=r["quotient"] } return temp -- cgit v1.2.1