diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2012-12-09 22:11:01 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2012-12-09 22:11:01 +0200 |
commit | ae9e583a257264f4580d07354e79aac63db72695 (patch) | |
tree | 5a03a771ec6588c0dede291c56df8ec9cb783f7a | |
parent | a5a114bf6c6f2efdcd7889ebf0d7f9f3ec235a74 (diff) | |
parent | d283194601bc7cb7c071317a8d53a89a3cbac40d (diff) | |
download | gawk-ae9e583a257264f4580d07354e79aac63db72695.tar.gz |
Merge branch 'master' into array-iface
-rw-r--r-- | ChangeLog | 41 | ||||
-rw-r--r-- | TODO | 4 | ||||
-rw-r--r-- | awk.h | 11 | ||||
-rw-r--r-- | awkgram.c | 396 | ||||
-rw-r--r-- | awkgram.y | 14 | ||||
-rw-r--r-- | builtin.c | 12 | ||||
-rw-r--r-- | cint_array.c | 12 | ||||
-rw-r--r-- | configh.in | 3 | ||||
-rwxr-xr-x | configure | 2 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | debug.c | 34 | ||||
-rw-r--r-- | doc/ChangeLog | 6 | ||||
-rw-r--r-- | doc/awkforai.txt | 158 | ||||
-rw-r--r-- | doc/gawk.info | 148 | ||||
-rw-r--r-- | doc/gawk.texi | 13 | ||||
-rw-r--r-- | eval.c | 32 | ||||
-rw-r--r-- | ext.c | 48 | ||||
-rw-r--r-- | gawkapi.c | 12 | ||||
-rw-r--r-- | int_array.c | 4 | ||||
-rw-r--r-- | io.c | 31 | ||||
-rw-r--r-- | main.c | 4 | ||||
-rw-r--r-- | mpfr.c | 6 | ||||
-rw-r--r-- | node.c | 12 | ||||
-rw-r--r-- | profile.c | 6 | ||||
-rw-r--r-- | regex.c | 2 | ||||
-rw-r--r-- | str_array.c | 4 | ||||
-rw-r--r-- | vms/ChangeLog | 4 | ||||
-rw-r--r-- | vms/vmstest.com | 177 |
28 files changed, 678 insertions, 520 deletions
@@ -1,3 +1,44 @@ +2012-12-09 Arnold D. Robbins <arnold@skeeve.com> + + Clean up BINMODE to use symbolic values. + + * awk.h (enum binmode_values): New enum. + * eval.c (set_BINMODE): Use them. + * io.c (binmode, close_rp, gawk_popen): Ditto. + * main.c (main): Ditto. + * builtin.c (do_system): Ditto. + + Unrelated: + + * configure.ac: Look for posix_openpt + * io.c (two_way_open): Use posix_openpt if it's available. + Thanks to Christian Weisgerber <naddy@mips.inka.de> for + the changes. + + Also unrelated: + + * regex.c: Don't include <sys/param.h> on VMS. Thanks to + Anders Wallin. + + Also unrelated: + + * ext.c (is_letter, is_identifier_char): New functions. Don't use + <ctype.h> functions since those could rely on the locale. + (make_builtin): Adjust test for valid name to call the new + functions and return false instead of throwing a fatal error. + (make_old_builtin): Adjust test for valid name to call the new + function. + * awk.h (is_identchar): Move from here, ... + * awkgram.y (is_identchar): ... to here. This is safe, since + the locale is C during parsing the program. + + Also unrelated: Make all checks for bitflags being set consistent + in case we should wish to switch them to macro calls: + + * awkgram.y, builtin.c, cint_array.c, debug.c, eval.c, gawkapi.c, + int_array.c, io.c, mpfr.c, node.c, profile.c, str_array.c: Fix + as needed. + 2012-12-07 Arnold D. Robbins <arnold@skeeve.com> * awkgram.y (tokentab): `fflush()' is now in POSIX, remove the @@ -22,7 +22,9 @@ Minor Cleanups and Code Improvements DONE: awk_true and awk_false DONE: Update doc to use gcc -o filefuncs.so -shared filefuncs.o instead of ld ... - Have check for name not rely on isalpha, isalnum since the locale could botch that up. + DONE: Have check for name not rely on isalpha, isalnum since + the locale could botch that up. Also make it not + fatal. ??? #if !defined(GAWK) && !defined(GAWK_OMIT_CONVENIENCE_MACROS) DONE: Make fflush() and fflush("") both flush all files, as in BWK awk. @@ -930,6 +930,15 @@ struct redirect { awk_output_buf_t output; }; +/* values for BINMODE, used as bit flags */ + +enum binmode_values { + TEXT_TRANSLATE = 0, /* usual \r\n ---> \n translation */ + BINMODE_INPUT = 1, /* no translation for input files */ + BINMODE_OUTPUT = 2, /* no translation for output files */ + BINMODE_BOTH = 3 /* no translation for either */ +}; + /* * structure for our source, either a command line string or a source file. */ @@ -1220,8 +1229,6 @@ DEREF(NODE *r) #define iszero(n) ((n)->numbr == 0.0) #endif -#define is_identchar(c) (isalnum(c) || (c) == '_') - #define var_uninitialized(n) ((n)->var_value == Nnull_string) #define get_lhs(n, r) (n)->type == Node_var && ! var_uninitialized(n) ? \ @@ -193,8 +193,10 @@ extern double fmod(double x, double y); #define YYSTYPE INSTRUCTION * +#define is_identchar(c) (isalnum(c) || (c) == '_') + /* Line 360 of yacc.c */ -#line 198 "awkgram.c" +#line 200 "awkgram.c" # ifndef YY_NULL # if defined __cplusplus && 201103L <= __cplusplus @@ -363,7 +365,7 @@ int yyparse (); /* Copy the second part of user declarations. */ /* Line 379 of yacc.c */ -#line 367 "awkgram.c" +#line 369 "awkgram.c" #ifdef short # undef short @@ -727,25 +729,25 @@ static const yytype_int16 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 195, 195, 197, 202, 203, 209, 221, 225, 236, - 242, 247, 255, 263, 265, 270, 278, 280, 286, 287, - 289, 315, 326, 337, 343, 352, 362, 364, 366, 372, - 377, 378, 382, 401, 400, 434, 436, 441, 442, 455, - 460, 461, 465, 467, 469, 476, 566, 608, 650, 763, - 770, 777, 787, 796, 805, 814, 825, 841, 840, 864, - 876, 876, 974, 974, 1007, 1037, 1043, 1044, 1050, 1051, - 1058, 1063, 1075, 1089, 1091, 1099, 1104, 1106, 1114, 1116, - 1125, 1126, 1134, 1139, 1139, 1150, 1154, 1162, 1163, 1166, - 1168, 1173, 1174, 1183, 1184, 1189, 1194, 1200, 1202, 1204, - 1211, 1212, 1218, 1219, 1224, 1226, 1231, 1233, 1235, 1237, - 1243, 1250, 1252, 1254, 1270, 1280, 1287, 1289, 1294, 1296, - 1298, 1306, 1308, 1313, 1315, 1320, 1322, 1324, 1374, 1376, - 1378, 1380, 1382, 1384, 1386, 1388, 1411, 1416, 1421, 1446, - 1452, 1454, 1456, 1458, 1460, 1462, 1467, 1471, 1503, 1505, - 1511, 1517, 1530, 1531, 1532, 1537, 1542, 1546, 1550, 1565, - 1578, 1583, 1619, 1637, 1638, 1644, 1645, 1650, 1652, 1659, - 1676, 1693, 1695, 1702, 1707, 1715, 1725, 1737, 1746, 1750, - 1754, 1758, 1762, 1766, 1769, 1771, 1775, 1779, 1783 + 0, 197, 197, 199, 204, 205, 211, 223, 227, 238, + 244, 249, 257, 265, 267, 272, 280, 282, 288, 289, + 291, 317, 328, 339, 345, 354, 364, 366, 368, 374, + 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, 1237, 1239, + 1245, 1252, 1254, 1256, 1272, 1282, 1289, 1291, 1296, 1298, + 1300, 1308, 1310, 1315, 1317, 1322, 1324, 1326, 1376, 1378, + 1380, 1382, 1384, 1386, 1388, 1390, 1413, 1418, 1423, 1448, + 1454, 1456, 1458, 1460, 1462, 1464, 1469, 1473, 1505, 1507, + 1513, 1519, 1532, 1533, 1534, 1539, 1544, 1548, 1552, 1567, + 1580, 1585, 1621, 1639, 1640, 1646, 1647, 1652, 1654, 1661, + 1678, 1695, 1697, 1704, 1709, 1717, 1727, 1739, 1748, 1752, + 1756, 1760, 1764, 1768, 1771, 1773, 1777, 1781, 1785 }; #endif @@ -2029,7 +2031,7 @@ yyreduce: { case 3: /* Line 1778 of yacc.c */ -#line 198 "awkgram.y" +#line 200 "awkgram.y" { rule = 0; yyerrok; @@ -2038,7 +2040,7 @@ yyreduce: case 5: /* Line 1778 of yacc.c */ -#line 204 "awkgram.y" +#line 206 "awkgram.y" { next_sourcefile(); if (sourcefile == srcfiles) @@ -2048,7 +2050,7 @@ yyreduce: case 6: /* Line 1778 of yacc.c */ -#line 210 "awkgram.y" +#line 212 "awkgram.y" { rule = 0; /* @@ -2061,7 +2063,7 @@ yyreduce: case 7: /* Line 1778 of yacc.c */ -#line 222 "awkgram.y" +#line 224 "awkgram.y" { (void) append_rule((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); } @@ -2069,7 +2071,7 @@ yyreduce: case 8: /* Line 1778 of yacc.c */ -#line 226 "awkgram.y" +#line 228 "awkgram.y" { if (rule != Rule) { msg(_("%s blocks must have an action part"), ruletab[rule]); @@ -2084,7 +2086,7 @@ yyreduce: case 9: /* Line 1778 of yacc.c */ -#line 237 "awkgram.y" +#line 239 "awkgram.y" { in_function = NULL; (void) mk_function((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); @@ -2094,7 +2096,7 @@ yyreduce: case 10: /* Line 1778 of yacc.c */ -#line 243 "awkgram.y" +#line 245 "awkgram.y" { want_source = false; yyerrok; @@ -2103,7 +2105,7 @@ yyreduce: case 11: /* Line 1778 of yacc.c */ -#line 248 "awkgram.y" +#line 250 "awkgram.y" { want_source = false; yyerrok; @@ -2112,7 +2114,7 @@ yyreduce: case 12: /* Line 1778 of yacc.c */ -#line 256 "awkgram.y" +#line 258 "awkgram.y" { if (include_source((yyvsp[(1) - (1)])) < 0) YYABORT; @@ -2124,19 +2126,19 @@ yyreduce: case 13: /* Line 1778 of yacc.c */ -#line 264 "awkgram.y" +#line 266 "awkgram.y" { (yyval) = NULL; } break; case 14: /* Line 1778 of yacc.c */ -#line 266 "awkgram.y" +#line 268 "awkgram.y" { (yyval) = NULL; } break; case 15: /* Line 1778 of yacc.c */ -#line 271 "awkgram.y" +#line 273 "awkgram.y" { if (load_library((yyvsp[(1) - (1)])) < 0) YYABORT; @@ -2148,31 +2150,31 @@ yyreduce: case 16: /* Line 1778 of yacc.c */ -#line 279 "awkgram.y" +#line 281 "awkgram.y" { (yyval) = NULL; } break; case 17: /* Line 1778 of yacc.c */ -#line 281 "awkgram.y" +#line 283 "awkgram.y" { (yyval) = NULL; } break; case 18: /* Line 1778 of yacc.c */ -#line 286 "awkgram.y" +#line 288 "awkgram.y" { (yyval) = NULL; rule = Rule; } break; case 19: /* Line 1778 of yacc.c */ -#line 288 "awkgram.y" +#line 290 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); rule = Rule; } break; case 20: /* Line 1778 of yacc.c */ -#line 290 "awkgram.y" +#line 292 "awkgram.y" { INSTRUCTION *tp; @@ -2202,7 +2204,7 @@ yyreduce: case 21: /* Line 1778 of yacc.c */ -#line 316 "awkgram.y" +#line 318 "awkgram.y" { static int begin_seen = 0; if (do_lint_old && ++begin_seen == 2) @@ -2217,7 +2219,7 @@ yyreduce: case 22: /* Line 1778 of yacc.c */ -#line 327 "awkgram.y" +#line 329 "awkgram.y" { static int end_seen = 0; if (do_lint_old && ++end_seen == 2) @@ -2232,7 +2234,7 @@ yyreduce: case 23: /* Line 1778 of yacc.c */ -#line 338 "awkgram.y" +#line 340 "awkgram.y" { (yyvsp[(1) - (1)])->in_rule = rule = BEGINFILE; (yyvsp[(1) - (1)])->source_file = source; @@ -2242,7 +2244,7 @@ yyreduce: case 24: /* Line 1778 of yacc.c */ -#line 344 "awkgram.y" +#line 346 "awkgram.y" { (yyvsp[(1) - (1)])->in_rule = rule = ENDFILE; (yyvsp[(1) - (1)])->source_file = source; @@ -2252,7 +2254,7 @@ yyreduce: case 25: /* Line 1778 of yacc.c */ -#line 353 "awkgram.y" +#line 355 "awkgram.y" { if ((yyvsp[(2) - (5)]) == NULL) (yyval) = list_create(instruction(Op_no_op)); @@ -2263,19 +2265,19 @@ yyreduce: case 26: /* Line 1778 of yacc.c */ -#line 363 "awkgram.y" +#line 365 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 27: /* Line 1778 of yacc.c */ -#line 365 "awkgram.y" +#line 367 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 28: /* Line 1778 of yacc.c */ -#line 367 "awkgram.y" +#line 369 "awkgram.y" { yyerror(_("`%s' is a built-in function, it cannot be redefined"), tokstart); @@ -2285,13 +2287,13 @@ yyreduce: case 29: /* Line 1778 of yacc.c */ -#line 373 "awkgram.y" +#line 375 "awkgram.y" { (yyval) = (yyvsp[(2) - (2)]); } break; case 32: /* Line 1778 of yacc.c */ -#line 383 "awkgram.y" +#line 385 "awkgram.y" { (yyvsp[(1) - (6)])->source_file = source; if (install_function((yyvsp[(2) - (6)])->lextok, (yyvsp[(1) - (6)]), (yyvsp[(4) - (6)])) < 0) @@ -2306,13 +2308,13 @@ yyreduce: case 33: /* Line 1778 of yacc.c */ -#line 401 "awkgram.y" +#line 403 "awkgram.y" { want_regexp = true; } break; case 34: /* Line 1778 of yacc.c */ -#line 403 "awkgram.y" +#line 405 "awkgram.y" { NODE *n, *exp; char *re; @@ -2345,19 +2347,19 @@ yyreduce: case 35: /* Line 1778 of yacc.c */ -#line 435 "awkgram.y" +#line 437 "awkgram.y" { bcfree((yyvsp[(1) - (1)])); } break; case 37: /* Line 1778 of yacc.c */ -#line 441 "awkgram.y" +#line 443 "awkgram.y" { (yyval) = NULL; } break; case 38: /* Line 1778 of yacc.c */ -#line 443 "awkgram.y" +#line 445 "awkgram.y" { if ((yyvsp[(2) - (2)]) == NULL) (yyval) = (yyvsp[(1) - (2)]); @@ -2374,25 +2376,25 @@ yyreduce: case 39: /* Line 1778 of yacc.c */ -#line 456 "awkgram.y" +#line 458 "awkgram.y" { (yyval) = NULL; } break; case 42: /* Line 1778 of yacc.c */ -#line 466 "awkgram.y" +#line 468 "awkgram.y" { (yyval) = NULL; } break; case 43: /* Line 1778 of yacc.c */ -#line 468 "awkgram.y" +#line 470 "awkgram.y" { (yyval) = (yyvsp[(2) - (3)]); } break; case 44: /* Line 1778 of yacc.c */ -#line 470 "awkgram.y" +#line 472 "awkgram.y" { if (do_pretty_print) (yyval) = list_prepend((yyvsp[(1) - (1)]), instruction(Op_exec_count)); @@ -2403,7 +2405,7 @@ yyreduce: case 45: /* Line 1778 of yacc.c */ -#line 477 "awkgram.y" +#line 479 "awkgram.y" { INSTRUCTION *dflt, *curr = NULL, *cexp, *cstmt; INSTRUCTION *ip, *nextc, *tbreak; @@ -2497,7 +2499,7 @@ yyreduce: case 46: /* Line 1778 of yacc.c */ -#line 567 "awkgram.y" +#line 569 "awkgram.y" { /* * ----------------- @@ -2543,7 +2545,7 @@ yyreduce: case 47: /* Line 1778 of yacc.c */ -#line 609 "awkgram.y" +#line 611 "awkgram.y" { /* * ----------------- @@ -2589,7 +2591,7 @@ yyreduce: case 48: /* Line 1778 of yacc.c */ -#line 651 "awkgram.y" +#line 653 "awkgram.y" { INSTRUCTION *ip; char *var_name = (yyvsp[(3) - (8)])->lextok; @@ -2706,7 +2708,7 @@ regular_loop: case 49: /* Line 1778 of yacc.c */ -#line 764 "awkgram.y" +#line 766 "awkgram.y" { (yyval) = mk_for_loop((yyvsp[(1) - (12)]), (yyvsp[(3) - (12)]), (yyvsp[(6) - (12)]), (yyvsp[(9) - (12)]), (yyvsp[(12) - (12)])); @@ -2717,7 +2719,7 @@ regular_loop: case 50: /* Line 1778 of yacc.c */ -#line 771 "awkgram.y" +#line 773 "awkgram.y" { (yyval) = mk_for_loop((yyvsp[(1) - (11)]), (yyvsp[(3) - (11)]), (INSTRUCTION *) NULL, (yyvsp[(8) - (11)]), (yyvsp[(11) - (11)])); @@ -2728,7 +2730,7 @@ regular_loop: case 51: /* Line 1778 of yacc.c */ -#line 778 "awkgram.y" +#line 780 "awkgram.y" { if (do_pretty_print) (yyval) = list_prepend((yyvsp[(1) - (1)]), instruction(Op_exec_count)); @@ -2739,7 +2741,7 @@ regular_loop: case 52: /* Line 1778 of yacc.c */ -#line 788 "awkgram.y" +#line 790 "awkgram.y" { if (! break_allowed) error_ln((yyvsp[(1) - (2)])->source_line, @@ -2752,7 +2754,7 @@ regular_loop: case 53: /* Line 1778 of yacc.c */ -#line 797 "awkgram.y" +#line 799 "awkgram.y" { if (! continue_allowed) error_ln((yyvsp[(1) - (2)])->source_line, @@ -2765,7 +2767,7 @@ regular_loop: case 54: /* Line 1778 of yacc.c */ -#line 806 "awkgram.y" +#line 808 "awkgram.y" { /* if inside function (rule = 0), resolve context at run-time */ if (rule && rule != Rule) @@ -2778,7 +2780,7 @@ regular_loop: case 55: /* Line 1778 of yacc.c */ -#line 815 "awkgram.y" +#line 817 "awkgram.y" { /* if inside function (rule = 0), resolve context at run-time */ if (rule == BEGIN || rule == END || rule == ENDFILE) @@ -2793,7 +2795,7 @@ regular_loop: case 56: /* Line 1778 of yacc.c */ -#line 826 "awkgram.y" +#line 828 "awkgram.y" { /* Initialize the two possible jump targets, the actual target * is resolved at run-time. @@ -2812,7 +2814,7 @@ regular_loop: case 57: /* Line 1778 of yacc.c */ -#line 841 "awkgram.y" +#line 843 "awkgram.y" { if (! in_function) yyerror(_("`return' used outside function context")); @@ -2821,7 +2823,7 @@ regular_loop: case 58: /* Line 1778 of yacc.c */ -#line 844 "awkgram.y" +#line 846 "awkgram.y" { if ((yyvsp[(3) - (4)]) == NULL) { (yyval) = list_create((yyvsp[(1) - (4)])); @@ -2846,13 +2848,13 @@ regular_loop: case 60: /* Line 1778 of yacc.c */ -#line 876 "awkgram.y" +#line 878 "awkgram.y" { in_print = true; in_parens = 0; } break; case 61: /* Line 1778 of yacc.c */ -#line 877 "awkgram.y" +#line 879 "awkgram.y" { /* * Optimization: plain `print' has no expression list, so $3 is null. @@ -2953,13 +2955,13 @@ regular_print: case 62: /* Line 1778 of yacc.c */ -#line 974 "awkgram.y" +#line 976 "awkgram.y" { sub_counter = 0; } break; case 63: /* Line 1778 of yacc.c */ -#line 975 "awkgram.y" +#line 977 "awkgram.y" { char *arr = (yyvsp[(2) - (4)])->lextok; @@ -2996,7 +2998,7 @@ regular_print: case 64: /* Line 1778 of yacc.c */ -#line 1012 "awkgram.y" +#line 1014 "awkgram.y" { static bool warned = false; char *arr = (yyvsp[(3) - (4)])->lextok; @@ -3026,31 +3028,31 @@ regular_print: case 65: /* Line 1778 of yacc.c */ -#line 1038 "awkgram.y" +#line 1040 "awkgram.y" { (yyval) = optimize_assignment((yyvsp[(1) - (1)])); } break; case 66: /* Line 1778 of yacc.c */ -#line 1043 "awkgram.y" +#line 1045 "awkgram.y" { (yyval) = NULL; } break; case 67: /* Line 1778 of yacc.c */ -#line 1045 "awkgram.y" +#line 1047 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 68: /* Line 1778 of yacc.c */ -#line 1050 "awkgram.y" +#line 1052 "awkgram.y" { (yyval) = NULL; } break; case 69: /* Line 1778 of yacc.c */ -#line 1052 "awkgram.y" +#line 1054 "awkgram.y" { if ((yyvsp[(1) - (2)]) == NULL) (yyval) = list_create((yyvsp[(2) - (2)])); @@ -3061,13 +3063,13 @@ regular_print: case 70: /* Line 1778 of yacc.c */ -#line 1059 "awkgram.y" +#line 1061 "awkgram.y" { (yyval) = NULL; } break; case 71: /* Line 1778 of yacc.c */ -#line 1064 "awkgram.y" +#line 1066 "awkgram.y" { INSTRUCTION *casestmt = (yyvsp[(5) - (5)]); if ((yyvsp[(5) - (5)]) == NULL) @@ -3083,7 +3085,7 @@ regular_print: case 72: /* Line 1778 of yacc.c */ -#line 1076 "awkgram.y" +#line 1078 "awkgram.y" { INSTRUCTION *casestmt = (yyvsp[(4) - (4)]); if ((yyvsp[(4) - (4)]) == NULL) @@ -3098,13 +3100,13 @@ regular_print: case 73: /* Line 1778 of yacc.c */ -#line 1090 "awkgram.y" +#line 1092 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 74: /* Line 1778 of yacc.c */ -#line 1092 "awkgram.y" +#line 1094 "awkgram.y" { NODE *n = (yyvsp[(2) - (2)])->memory; (void) force_number(n); @@ -3116,7 +3118,7 @@ regular_print: case 75: /* Line 1778 of yacc.c */ -#line 1100 "awkgram.y" +#line 1102 "awkgram.y" { bcfree((yyvsp[(1) - (2)])); (yyval) = (yyvsp[(2) - (2)]); @@ -3125,13 +3127,13 @@ regular_print: case 76: /* Line 1778 of yacc.c */ -#line 1105 "awkgram.y" +#line 1107 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 77: /* Line 1778 of yacc.c */ -#line 1107 "awkgram.y" +#line 1109 "awkgram.y" { (yyvsp[(1) - (1)])->opcode = Op_push_re; (yyval) = (yyvsp[(1) - (1)]); @@ -3140,19 +3142,19 @@ regular_print: case 78: /* Line 1778 of yacc.c */ -#line 1115 "awkgram.y" +#line 1117 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 79: /* Line 1778 of yacc.c */ -#line 1117 "awkgram.y" +#line 1119 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 81: /* Line 1778 of yacc.c */ -#line 1127 "awkgram.y" +#line 1129 "awkgram.y" { (yyval) = (yyvsp[(2) - (3)]); } @@ -3160,7 +3162,7 @@ regular_print: case 82: /* Line 1778 of yacc.c */ -#line 1134 "awkgram.y" +#line 1136 "awkgram.y" { in_print = false; in_parens = 0; @@ -3170,13 +3172,13 @@ regular_print: case 83: /* Line 1778 of yacc.c */ -#line 1139 "awkgram.y" +#line 1141 "awkgram.y" { in_print = false; in_parens = 0; } break; case 84: /* Line 1778 of yacc.c */ -#line 1140 "awkgram.y" +#line 1142 "awkgram.y" { if ((yyvsp[(1) - (3)])->redir_type == redirect_twoway && (yyvsp[(3) - (3)])->lasti->opcode == Op_K_getline_redir @@ -3188,7 +3190,7 @@ regular_print: case 85: /* Line 1778 of yacc.c */ -#line 1151 "awkgram.y" +#line 1153 "awkgram.y" { (yyval) = mk_condition((yyvsp[(3) - (6)]), (yyvsp[(1) - (6)]), (yyvsp[(6) - (6)]), NULL, NULL); } @@ -3196,7 +3198,7 @@ regular_print: case 86: /* Line 1778 of yacc.c */ -#line 1156 "awkgram.y" +#line 1158 "awkgram.y" { (yyval) = mk_condition((yyvsp[(3) - (9)]), (yyvsp[(1) - (9)]), (yyvsp[(6) - (9)]), (yyvsp[(7) - (9)]), (yyvsp[(9) - (9)])); } @@ -3204,13 +3206,13 @@ regular_print: case 91: /* Line 1778 of yacc.c */ -#line 1173 "awkgram.y" +#line 1175 "awkgram.y" { (yyval) = NULL; } break; case 92: /* Line 1778 of yacc.c */ -#line 1175 "awkgram.y" +#line 1177 "awkgram.y" { bcfree((yyvsp[(1) - (2)])); (yyval) = (yyvsp[(2) - (2)]); @@ -3219,19 +3221,19 @@ regular_print: case 93: /* Line 1778 of yacc.c */ -#line 1183 "awkgram.y" +#line 1185 "awkgram.y" { (yyval) = NULL; } break; case 94: /* Line 1778 of yacc.c */ -#line 1185 "awkgram.y" +#line 1187 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]) ; } break; case 95: /* Line 1778 of yacc.c */ -#line 1190 "awkgram.y" +#line 1192 "awkgram.y" { (yyvsp[(1) - (1)])->param_count = 0; (yyval) = list_create((yyvsp[(1) - (1)])); @@ -3240,7 +3242,7 @@ regular_print: case 96: /* Line 1778 of yacc.c */ -#line 1195 "awkgram.y" +#line 1197 "awkgram.y" { (yyvsp[(3) - (3)])->param_count = (yyvsp[(1) - (3)])->lasti->param_count + 1; (yyval) = list_append((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); @@ -3250,55 +3252,55 @@ regular_print: case 97: /* Line 1778 of yacc.c */ -#line 1201 "awkgram.y" +#line 1203 "awkgram.y" { (yyval) = NULL; } break; case 98: /* Line 1778 of yacc.c */ -#line 1203 "awkgram.y" +#line 1205 "awkgram.y" { (yyval) = (yyvsp[(1) - (2)]); } break; case 99: /* Line 1778 of yacc.c */ -#line 1205 "awkgram.y" +#line 1207 "awkgram.y" { (yyval) = (yyvsp[(1) - (3)]); } break; case 100: /* Line 1778 of yacc.c */ -#line 1211 "awkgram.y" +#line 1213 "awkgram.y" { (yyval) = NULL; } break; case 101: /* Line 1778 of yacc.c */ -#line 1213 "awkgram.y" +#line 1215 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 102: /* Line 1778 of yacc.c */ -#line 1218 "awkgram.y" +#line 1220 "awkgram.y" { (yyval) = NULL; } break; case 103: /* Line 1778 of yacc.c */ -#line 1220 "awkgram.y" +#line 1222 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 104: /* Line 1778 of yacc.c */ -#line 1225 "awkgram.y" +#line 1227 "awkgram.y" { (yyval) = mk_expression_list(NULL, (yyvsp[(1) - (1)])); } break; case 105: /* Line 1778 of yacc.c */ -#line 1227 "awkgram.y" +#line 1229 "awkgram.y" { (yyval) = mk_expression_list((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); yyerrok; @@ -3307,31 +3309,31 @@ regular_print: case 106: /* Line 1778 of yacc.c */ -#line 1232 "awkgram.y" +#line 1234 "awkgram.y" { (yyval) = NULL; } break; case 107: /* Line 1778 of yacc.c */ -#line 1234 "awkgram.y" +#line 1236 "awkgram.y" { (yyval) = NULL; } break; case 108: /* Line 1778 of yacc.c */ -#line 1236 "awkgram.y" +#line 1238 "awkgram.y" { (yyval) = NULL; } break; case 109: /* Line 1778 of yacc.c */ -#line 1238 "awkgram.y" +#line 1240 "awkgram.y" { (yyval) = NULL; } break; case 110: /* Line 1778 of yacc.c */ -#line 1244 "awkgram.y" +#line 1246 "awkgram.y" { if (do_lint && (yyvsp[(3) - (3)])->lasti->opcode == Op_match_rec) lintwarn_ln((yyvsp[(2) - (3)])->source_line, @@ -3342,19 +3344,19 @@ regular_print: case 111: /* Line 1778 of yacc.c */ -#line 1251 "awkgram.y" +#line 1253 "awkgram.y" { (yyval) = mk_boolean((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 112: /* Line 1778 of yacc.c */ -#line 1253 "awkgram.y" +#line 1255 "awkgram.y" { (yyval) = mk_boolean((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 113: /* Line 1778 of yacc.c */ -#line 1255 "awkgram.y" +#line 1257 "awkgram.y" { if ((yyvsp[(1) - (3)])->lasti->opcode == Op_match_rec) warning_ln((yyvsp[(2) - (3)])->source_line, @@ -3374,7 +3376,7 @@ regular_print: case 114: /* Line 1778 of yacc.c */ -#line 1271 "awkgram.y" +#line 1273 "awkgram.y" { if (do_lint_old) warning_ln((yyvsp[(2) - (3)])->source_line, @@ -3388,7 +3390,7 @@ regular_print: case 115: /* Line 1778 of yacc.c */ -#line 1281 "awkgram.y" +#line 1283 "awkgram.y" { if (do_lint && (yyvsp[(3) - (3)])->lasti->opcode == Op_match_rec) lintwarn_ln((yyvsp[(2) - (3)])->source_line, @@ -3399,31 +3401,31 @@ regular_print: case 116: /* Line 1778 of yacc.c */ -#line 1288 "awkgram.y" +#line 1290 "awkgram.y" { (yyval) = mk_condition((yyvsp[(1) - (5)]), (yyvsp[(2) - (5)]), (yyvsp[(3) - (5)]), (yyvsp[(4) - (5)]), (yyvsp[(5) - (5)])); } break; case 117: /* Line 1778 of yacc.c */ -#line 1290 "awkgram.y" +#line 1292 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 118: /* Line 1778 of yacc.c */ -#line 1295 "awkgram.y" +#line 1297 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 119: /* Line 1778 of yacc.c */ -#line 1297 "awkgram.y" +#line 1299 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 120: /* Line 1778 of yacc.c */ -#line 1299 "awkgram.y" +#line 1301 "awkgram.y" { (yyvsp[(2) - (2)])->opcode = Op_assign_quotient; (yyval) = (yyvsp[(2) - (2)]); @@ -3432,43 +3434,43 @@ regular_print: case 121: /* Line 1778 of yacc.c */ -#line 1307 "awkgram.y" +#line 1309 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 122: /* Line 1778 of yacc.c */ -#line 1309 "awkgram.y" +#line 1311 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 123: /* Line 1778 of yacc.c */ -#line 1314 "awkgram.y" +#line 1316 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 124: /* Line 1778 of yacc.c */ -#line 1316 "awkgram.y" +#line 1318 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 125: /* Line 1778 of yacc.c */ -#line 1321 "awkgram.y" +#line 1323 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 126: /* Line 1778 of yacc.c */ -#line 1323 "awkgram.y" +#line 1325 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 127: /* Line 1778 of yacc.c */ -#line 1325 "awkgram.y" +#line 1327 "awkgram.y" { int count = 2; bool is_simple_var = false; @@ -3519,43 +3521,43 @@ regular_print: case 129: /* Line 1778 of yacc.c */ -#line 1377 "awkgram.y" +#line 1379 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 130: /* Line 1778 of yacc.c */ -#line 1379 "awkgram.y" +#line 1381 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 131: /* Line 1778 of yacc.c */ -#line 1381 "awkgram.y" +#line 1383 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 132: /* Line 1778 of yacc.c */ -#line 1383 "awkgram.y" +#line 1385 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 133: /* Line 1778 of yacc.c */ -#line 1385 "awkgram.y" +#line 1387 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 134: /* Line 1778 of yacc.c */ -#line 1387 "awkgram.y" +#line 1389 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 135: /* Line 1778 of yacc.c */ -#line 1389 "awkgram.y" +#line 1391 "awkgram.y" { /* * In BEGINFILE/ENDFILE, allow `getline var < file' @@ -3582,7 +3584,7 @@ regular_print: case 136: /* Line 1778 of yacc.c */ -#line 1412 "awkgram.y" +#line 1414 "awkgram.y" { (yyvsp[(2) - (2)])->opcode = Op_postincrement; (yyval) = mk_assignment((yyvsp[(1) - (2)]), NULL, (yyvsp[(2) - (2)])); @@ -3591,7 +3593,7 @@ regular_print: case 137: /* Line 1778 of yacc.c */ -#line 1417 "awkgram.y" +#line 1419 "awkgram.y" { (yyvsp[(2) - (2)])->opcode = Op_postdecrement; (yyval) = mk_assignment((yyvsp[(1) - (2)]), NULL, (yyvsp[(2) - (2)])); @@ -3600,7 +3602,7 @@ regular_print: case 138: /* Line 1778 of yacc.c */ -#line 1422 "awkgram.y" +#line 1424 "awkgram.y" { if (do_lint_old) { warning_ln((yyvsp[(4) - (5)])->source_line, @@ -3624,7 +3626,7 @@ regular_print: case 139: /* Line 1778 of yacc.c */ -#line 1447 "awkgram.y" +#line 1449 "awkgram.y" { (yyval) = mk_getline((yyvsp[(3) - (4)]), (yyvsp[(4) - (4)]), (yyvsp[(1) - (4)]), (yyvsp[(2) - (4)])->redir_type); bcfree((yyvsp[(2) - (4)])); @@ -3633,43 +3635,43 @@ regular_print: case 140: /* Line 1778 of yacc.c */ -#line 1453 "awkgram.y" +#line 1455 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 141: /* Line 1778 of yacc.c */ -#line 1455 "awkgram.y" +#line 1457 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 142: /* Line 1778 of yacc.c */ -#line 1457 "awkgram.y" +#line 1459 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 143: /* Line 1778 of yacc.c */ -#line 1459 "awkgram.y" +#line 1461 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 144: /* Line 1778 of yacc.c */ -#line 1461 "awkgram.y" +#line 1463 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 145: /* Line 1778 of yacc.c */ -#line 1463 "awkgram.y" +#line 1465 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 146: /* Line 1778 of yacc.c */ -#line 1468 "awkgram.y" +#line 1470 "awkgram.y" { (yyval) = list_create((yyvsp[(1) - (1)])); } @@ -3677,7 +3679,7 @@ regular_print: case 147: /* Line 1778 of yacc.c */ -#line 1472 "awkgram.y" +#line 1474 "awkgram.y" { if ((yyvsp[(2) - (2)])->opcode == Op_match_rec) { (yyvsp[(2) - (2)])->opcode = Op_nomatch; @@ -3713,13 +3715,13 @@ regular_print: case 148: /* Line 1778 of yacc.c */ -#line 1504 "awkgram.y" +#line 1506 "awkgram.y" { (yyval) = (yyvsp[(2) - (3)]); } break; case 149: /* Line 1778 of yacc.c */ -#line 1506 "awkgram.y" +#line 1508 "awkgram.y" { (yyval) = snode((yyvsp[(3) - (4)]), (yyvsp[(1) - (4)])); if ((yyval) == NULL) @@ -3729,7 +3731,7 @@ regular_print: case 150: /* Line 1778 of yacc.c */ -#line 1512 "awkgram.y" +#line 1514 "awkgram.y" { (yyval) = snode((yyvsp[(3) - (4)]), (yyvsp[(1) - (4)])); if ((yyval) == NULL) @@ -3739,7 +3741,7 @@ regular_print: case 151: /* Line 1778 of yacc.c */ -#line 1518 "awkgram.y" +#line 1520 "awkgram.y" { static bool warned = false; @@ -3756,7 +3758,7 @@ regular_print: case 154: /* Line 1778 of yacc.c */ -#line 1533 "awkgram.y" +#line 1535 "awkgram.y" { (yyvsp[(1) - (2)])->opcode = Op_preincrement; (yyval) = mk_assignment((yyvsp[(2) - (2)]), NULL, (yyvsp[(1) - (2)])); @@ -3765,7 +3767,7 @@ regular_print: case 155: /* Line 1778 of yacc.c */ -#line 1538 "awkgram.y" +#line 1540 "awkgram.y" { (yyvsp[(1) - (2)])->opcode = Op_predecrement; (yyval) = mk_assignment((yyvsp[(2) - (2)]), NULL, (yyvsp[(1) - (2)])); @@ -3774,7 +3776,7 @@ regular_print: case 156: /* Line 1778 of yacc.c */ -#line 1543 "awkgram.y" +#line 1545 "awkgram.y" { (yyval) = list_create((yyvsp[(1) - (1)])); } @@ -3782,7 +3784,7 @@ regular_print: case 157: /* Line 1778 of yacc.c */ -#line 1547 "awkgram.y" +#line 1549 "awkgram.y" { (yyval) = list_create((yyvsp[(1) - (1)])); } @@ -3790,7 +3792,7 @@ regular_print: case 158: /* Line 1778 of yacc.c */ -#line 1551 "awkgram.y" +#line 1553 "awkgram.y" { if ((yyvsp[(2) - (2)])->lasti->opcode == Op_push_i && ((yyvsp[(2) - (2)])->lasti->memory->flags & (STRCUR|STRING)) == 0 @@ -3809,7 +3811,7 @@ regular_print: case 159: /* Line 1778 of yacc.c */ -#line 1566 "awkgram.y" +#line 1568 "awkgram.y" { /* * was: $$ = $2 @@ -3823,7 +3825,7 @@ regular_print: case 160: /* Line 1778 of yacc.c */ -#line 1579 "awkgram.y" +#line 1581 "awkgram.y" { func_use((yyvsp[(1) - (1)])->lasti->func_name, FUNC_USE); (yyval) = (yyvsp[(1) - (1)]); @@ -3832,7 +3834,7 @@ regular_print: case 161: /* Line 1778 of yacc.c */ -#line 1584 "awkgram.y" +#line 1586 "awkgram.y" { /* indirect function call */ INSTRUCTION *f, *t; @@ -3869,7 +3871,7 @@ regular_print: case 162: /* Line 1778 of yacc.c */ -#line 1620 "awkgram.y" +#line 1622 "awkgram.y" { param_sanity((yyvsp[(3) - (4)])); (yyvsp[(1) - (4)])->opcode = Op_func_call; @@ -3887,37 +3889,37 @@ regular_print: case 163: /* Line 1778 of yacc.c */ -#line 1637 "awkgram.y" +#line 1639 "awkgram.y" { (yyval) = NULL; } break; case 164: /* Line 1778 of yacc.c */ -#line 1639 "awkgram.y" +#line 1641 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 165: /* Line 1778 of yacc.c */ -#line 1644 "awkgram.y" +#line 1646 "awkgram.y" { (yyval) = NULL; } break; case 166: /* Line 1778 of yacc.c */ -#line 1646 "awkgram.y" +#line 1648 "awkgram.y" { (yyval) = (yyvsp[(1) - (2)]); } break; case 167: /* Line 1778 of yacc.c */ -#line 1651 "awkgram.y" +#line 1653 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 168: /* Line 1778 of yacc.c */ -#line 1653 "awkgram.y" +#line 1655 "awkgram.y" { (yyval) = list_merge((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); } @@ -3925,7 +3927,7 @@ regular_print: case 169: /* Line 1778 of yacc.c */ -#line 1660 "awkgram.y" +#line 1662 "awkgram.y" { INSTRUCTION *ip = (yyvsp[(1) - (1)])->lasti; int count = ip->sub_count; /* # of SUBSEP-seperated expressions */ @@ -3943,7 +3945,7 @@ regular_print: case 170: /* Line 1778 of yacc.c */ -#line 1677 "awkgram.y" +#line 1679 "awkgram.y" { INSTRUCTION *t = (yyvsp[(2) - (3)]); if ((yyvsp[(2) - (3)]) == NULL) { @@ -3961,13 +3963,13 @@ regular_print: case 171: /* Line 1778 of yacc.c */ -#line 1694 "awkgram.y" +#line 1696 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 172: /* Line 1778 of yacc.c */ -#line 1696 "awkgram.y" +#line 1698 "awkgram.y" { (yyval) = list_merge((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); } @@ -3975,13 +3977,13 @@ regular_print: case 173: /* Line 1778 of yacc.c */ -#line 1703 "awkgram.y" +#line 1705 "awkgram.y" { (yyval) = (yyvsp[(1) - (2)]); } break; case 174: /* Line 1778 of yacc.c */ -#line 1708 "awkgram.y" +#line 1710 "awkgram.y" { char *var_name = (yyvsp[(1) - (1)])->lextok; @@ -3993,7 +3995,7 @@ regular_print: case 175: /* Line 1778 of yacc.c */ -#line 1716 "awkgram.y" +#line 1718 "awkgram.y" { char *arr = (yyvsp[(1) - (2)])->lextok; (yyvsp[(1) - (2)])->memory = variable((yyvsp[(1) - (2)])->source_line, arr, Node_var_new); @@ -4004,7 +4006,7 @@ regular_print: case 176: /* Line 1778 of yacc.c */ -#line 1726 "awkgram.y" +#line 1728 "awkgram.y" { INSTRUCTION *ip = (yyvsp[(1) - (1)])->nexti; if (ip->opcode == Op_push @@ -4020,7 +4022,7 @@ regular_print: case 177: /* Line 1778 of yacc.c */ -#line 1738 "awkgram.y" +#line 1740 "awkgram.y" { (yyval) = list_append((yyvsp[(2) - (3)]), (yyvsp[(1) - (3)])); if ((yyvsp[(3) - (3)]) != NULL) @@ -4030,7 +4032,7 @@ regular_print: case 178: /* Line 1778 of yacc.c */ -#line 1747 "awkgram.y" +#line 1749 "awkgram.y" { (yyvsp[(1) - (1)])->opcode = Op_postincrement; } @@ -4038,7 +4040,7 @@ regular_print: case 179: /* Line 1778 of yacc.c */ -#line 1751 "awkgram.y" +#line 1753 "awkgram.y" { (yyvsp[(1) - (1)])->opcode = Op_postdecrement; } @@ -4046,43 +4048,43 @@ regular_print: case 180: /* Line 1778 of yacc.c */ -#line 1754 "awkgram.y" +#line 1756 "awkgram.y" { (yyval) = NULL; } break; case 182: /* Line 1778 of yacc.c */ -#line 1762 "awkgram.y" +#line 1764 "awkgram.y" { yyerrok; } break; case 183: /* Line 1778 of yacc.c */ -#line 1766 "awkgram.y" +#line 1768 "awkgram.y" { yyerrok; } break; case 186: /* Line 1778 of yacc.c */ -#line 1775 "awkgram.y" +#line 1777 "awkgram.y" { yyerrok; } break; case 187: /* Line 1778 of yacc.c */ -#line 1779 "awkgram.y" +#line 1781 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); yyerrok; } break; case 188: /* Line 1778 of yacc.c */ -#line 1783 "awkgram.y" +#line 1785 "awkgram.y" { yyerrok; } break; /* Line 1778 of yacc.c */ -#line 4098 "awkgram.c" +#line 4100 "awkgram.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -4314,7 +4316,7 @@ yyreturn: /* Line 2041 of yacc.c */ -#line 1785 "awkgram.y" +#line 1787 "awkgram.y" struct token { @@ -6136,28 +6138,28 @@ retry: goto out; if (do_lint) { - if ((tokentab[mid].flags & GAWKX) && ! (warntab[mid] & GAWKX)) { + if ((tokentab[mid].flags & GAWKX) != 0 && (warntab[mid] & GAWKX) == 0) { lintwarn(_("`%s' is a gawk extension"), tokentab[mid].operator); warntab[mid] |= GAWKX; } - if ((tokentab[mid].flags & NOT_POSIX) && ! (warntab[mid] & NOT_POSIX)) { + if ((tokentab[mid].flags & NOT_POSIX) != 0 && (warntab[mid] & NOT_POSIX) == 0) { lintwarn(_("POSIX does not allow `%s'"), tokentab[mid].operator); warntab[mid] |= NOT_POSIX; } } - if (do_lint_old && (tokentab[mid].flags & NOT_OLD) - && ! (warntab[mid] & NOT_OLD) + if (do_lint_old && (tokentab[mid].flags & NOT_OLD) != 0 + && (warntab[mid] & NOT_OLD) == 0 ) { warning(_("`%s' is not supported in old awk"), tokentab[mid].operator); warntab[mid] |= NOT_OLD; } - if (tokentab[mid].flags & BREAK) + if ((tokentab[mid].flags & BREAK) != 0) break_allowed++; - if (tokentab[mid].flags & CONTINUE) + if ((tokentab[mid].flags & CONTINUE) != 0) continue_allowed++; switch (class) { @@ -151,6 +151,8 @@ static inline INSTRUCTION *list_merge(INSTRUCTION *l1, INSTRUCTION *l2); extern double fmod(double x, double y); #define YYSTYPE INSTRUCTION * + +#define is_identchar(c) (isalnum(c) || (c) == '_') %} %token FUNC_CALL NAME REGEXP FILENAME @@ -3603,28 +3605,28 @@ retry: goto out; if (do_lint) { - if ((tokentab[mid].flags & GAWKX) && ! (warntab[mid] & GAWKX)) { + if ((tokentab[mid].flags & GAWKX) != 0 && (warntab[mid] & GAWKX) == 0) { lintwarn(_("`%s' is a gawk extension"), tokentab[mid].operator); warntab[mid] |= GAWKX; } - if ((tokentab[mid].flags & NOT_POSIX) && ! (warntab[mid] & NOT_POSIX)) { + if ((tokentab[mid].flags & NOT_POSIX) != 0 && (warntab[mid] & NOT_POSIX) == 0) { lintwarn(_("POSIX does not allow `%s'"), tokentab[mid].operator); warntab[mid] |= NOT_POSIX; } } - if (do_lint_old && (tokentab[mid].flags & NOT_OLD) - && ! (warntab[mid] & NOT_OLD) + if (do_lint_old && (tokentab[mid].flags & NOT_OLD) != 0 + && (warntab[mid] & NOT_OLD) == 0 ) { warning(_("`%s' is not supported in old awk"), tokentab[mid].operator); warntab[mid] |= NOT_OLD; } - if (tokentab[mid].flags & BREAK) + if ((tokentab[mid].flags & BREAK) != 0) break_allowed++; - if (tokentab[mid].flags & CONTINUE) + if ((tokentab[mid].flags & CONTINUE) != 0) continue_allowed++; switch (class) { @@ -111,7 +111,7 @@ efwrite(const void *ptr, goto wrerror; if (flush && ((fp == stdout && output_is_tty) - || (rp != NULL && (rp->flag & RED_NOBUF)))) { + || (rp != NULL && (rp->flag & RED_NOBUF) != 0))) { if (rp != NULL) { rp->output.gawk_fflush(fp, rp->output.opaque); if (rp->output.gawk_ferror(fp, rp->output.opaque)) @@ -220,7 +220,7 @@ do_fflush(int nargs) status = -1; if (rp != NULL) { if ((rp->flag & (RED_WRITE|RED_APPEND)) == 0) { - if (rp->flag & RED_PIPE) + if ((rp->flag & RED_PIPE) != 0) warning(_("fflush: cannot flush: pipe `%s' opened for reading, not writing"), file); else @@ -1053,7 +1053,7 @@ check_pos: /* user input that looks numeric is numeric */ if ((arg->flags & (MAYBE_NUM|NUMBER)) == MAYBE_NUM) (void) force_number(arg); - if (arg->flags & NUMBER) { + if ((arg->flags & NUMBER) != 0) { uval = get_number_uj(arg); #if MBS_SUPPORT if (gawk_mb_cur_max > 1) { @@ -2043,7 +2043,7 @@ do_system(int nargs) ret = system(cmd); if (ret != -1) ret = WEXITSTATUS(ret); - if ((BINMODE & 1) != 0) + if ((BINMODE & BINMODE_INPUT) != 0) os_setbinmode(fileno(stdin), O_BINARY); cmd[tmp->stlen] = save; @@ -2766,7 +2766,7 @@ set_how_many: repllen--; ampersands++; } else if (*scan == '\\') { - if (flags & GENSUB) { /* gensub, behave sanely */ + if ((flags & GENSUB) != 0) { /* gensub, behave sanely */ if (isdigit((unsigned char) scan[1])) { ampersands++; scan++; @@ -2959,7 +2959,7 @@ done: } /* For a string literal, must not change the original string. */ - if (flags & LITERAL) + if ((flags & LITERAL) != 0) DEREF(t); else if (matches > 0) { unref(*lhs); diff --git a/cint_array.c b/cint_array.c index d30f0d01..29b6fdff 100644 --- a/cint_array.c +++ b/cint_array.c @@ -457,7 +457,7 @@ cint_list(NODE *symbol, NODE *t) /* populate it with index in ascending or descending order */ for (ja = NHAT, jd = INT32_BIT - 1; ja < INT32_BIT && jd >= NHAT; ) { - j = (assoc_kind & ADESC) ? jd-- : ja++; + j = (assoc_kind & ADESC) != 0 ? jd-- : ja++; tn = symbol->nodes[j]; if (tn == NULL) continue; @@ -896,7 +896,7 @@ tree_list(NODE *tree, NODE **list, assoc_kind_t assoc_kind) hsize /= 2; for (j = 0; j < hsize; j++) { - cj = (assoc_kind & ADESC) ? (hsize - 1 - j) : j; + cj = (assoc_kind & ADESC) != 0 ? (hsize - 1 - j) : j; tn = tree->nodes[cj]; if (tn == NULL) continue; @@ -1011,7 +1011,7 @@ tree_print(NODE *tree, size_t bi, int indent_level) hsize /= 2; fprintf(output_fp, "%4lu:%s[%4lu:%-4lu]\n", (unsigned long) bi, - (tree->flags & HALFHAT) ? "HH" : "H", + (tree->flags & HALFHAT) != 0 ? "HH" : "H", (unsigned long) hsize, (unsigned long) tree->table_size); for (j = 0; j < hsize; j++) { @@ -1158,14 +1158,14 @@ leaf_list(NODE *array, NODE **list, assoc_kind_t assoc_kind) static char buf[100]; for (i = 0; i < size; i++) { - ci = (assoc_kind & ADESC) ? (size - 1 - i) : i; + ci = (assoc_kind & ADESC) != 0 ? (size - 1 - i) : i; r = array->nodes[ci]; if (r == NULL) continue; /* index */ num = array->array_base + ci; - if (assoc_kind & AISTR) { + if ((assoc_kind & AISTR) != 0) { sprintf(buf, "%ld", num); subs = make_string(buf, strlen(buf)); subs->numbr = num; @@ -1177,7 +1177,7 @@ leaf_list(NODE *array, NODE **list, assoc_kind_t assoc_kind) list[k++] = subs; /* value */ - if (assoc_kind & AVALUE) { + if ((assoc_kind & AVALUE) != 0) { if (r->type == Node_val) { if ((assoc_kind & AVNUM) != 0) (void) force_number(r); @@ -159,6 +159,9 @@ /* Define to 1 if you have the <netinet/in.h> header file. */ #undef HAVE_NETINET_IN_H +/* Define to 1 if you have the `posix_openpt' function. */ +#undef HAVE_POSIX_OPENPT + /* Define to 1 if you have the `setenv' function. */ #undef HAVE_SETENV @@ -9962,7 +9962,7 @@ esac for ac_func in atexit btowc fmod getgrent getgroups grantpt \ isascii iswctype iswlower iswupper mbrlen \ memcmp memcpy memcpy_ulong memmove memset \ - memset_ulong mkstemp setenv setlocale setsid snprintf strchr \ + memset_ulong mkstemp posix_openpt setenv setlocale setsid snprintf strchr \ strerror strftime strncasecmp strcoll strtod strtoul \ system tmpfile towlower towupper tzset usleep wcrtomb \ wcscoll wctype diff --git a/configure.ac b/configure.ac index 8d82747e..bccd2351 100644 --- a/configure.ac +++ b/configure.ac @@ -275,7 +275,7 @@ esac AC_CHECK_FUNCS(atexit btowc fmod getgrent getgroups grantpt \ isascii iswctype iswlower iswupper mbrlen \ memcmp memcpy memcpy_ulong memmove memset \ - memset_ulong mkstemp setenv setlocale setsid snprintf strchr \ + memset_ulong mkstemp posix_openpt setenv setlocale setsid snprintf strchr \ strerror strftime strncasecmp strcoll strtod strtoul \ system tmpfile towlower towupper tzset usleep wcrtomb \ wcscoll wctype) @@ -745,16 +745,16 @@ do_info(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) gprintf(out_fp, _("Number Disp Enabled Location\n\n")); for (b = breakpoints.prev; b != &breakpoints; b = b->prev) { char *disp = "keep"; - if (b->flags & BP_ENABLE_ONCE) + if ((b->flags & BP_ENABLE_ONCE) != 0) disp = "dis"; - else if(b->flags & BP_TEMP) + else if ((b->flags & BP_TEMP) != 0) disp = "del"; gprintf(out_fp, "%-6d %-4.4s %-7.7s file %s, line #%d\n", - b->number, disp, (b->flags & BP_ENABLE) ? "yes" : "no", + b->number, disp, (b->flags & BP_ENABLE) != 0 ? "yes" : "no", b->src, b->bpi->source_line); if (b->hit_count > 0) gprintf(out_fp, _("\tno of hits = %ld\n"), b->hit_count); - if (b->flags & BP_IGNORE) + if ((b->flags & BP_IGNORE) != 0) gprintf(out_fp, _("\tignore next %ld hit(s)\n"), b->ignore_count); if (b->cndn.code != NULL) gprintf(out_fp, _("\tstop condition: %s\n"), b->cndn.expr); @@ -2172,8 +2172,8 @@ add_breakpoint(INSTRUCTION *prevp, INSTRUCTION *ip, char *src, bool silent) * This is more verbose that it might otherwise be, * in order to provide easily translatable strings. */ - if (b->flags & BP_ENABLE) { - if (b->flags & BP_IGNORE) + if ((b->flags & BP_ENABLE) != 0) { + if ((b->flags & BP_IGNORE) != 0) fprintf(out_fp, _("Note: breakpoint %d (enabled, ignore next %ld hits), also set at %s:%d"), b->number, @@ -2187,7 +2187,7 @@ add_breakpoint(INSTRUCTION *prevp, INSTRUCTION *ip, char *src, bool silent) b->src, lineno); } else { - if (b->flags & BP_IGNORE) + if ((b->flags & BP_IGNORE) != 0) fprintf(out_fp, _("Note: breakpoint %d (disabled, ignore next %ld hits), also set at %s:%d"), b->number, @@ -2402,7 +2402,7 @@ breakpoint_triggered(BREAKPOINT *b) return 0; b->hit_count++; - if (b->flags & BP_ENABLE_ONCE) { + if ((b->flags & BP_ENABLE_ONCE) != 0) { b->flags &= ~BP_ENABLE_ONCE; b->flags &= ~BP_ENABLE; } @@ -3404,9 +3404,9 @@ else \ valinfo(w->V, fprintf, out_fp); fprintf(out_fp, " Old value: "); - print_value((w->flags & OLD_IS_ARRAY), old_size, old_value); + print_value((w->flags & OLD_IS_ARRAY) != 0, old_size, old_value); fprintf(out_fp, " New value: "); - print_value((w->flags & CUR_IS_ARRAY), cur_size, cur_value); + print_value((w->flags & CUR_IS_ARRAY) != 0, cur_size, cur_value); #undef print_value } @@ -3656,9 +3656,9 @@ print_memory(NODE *m, NODE *func, Func_print print_func, FILE *fp) print_func(fp, "Nnull_string"); else if ((m->flags & NUMBER) != 0) { #ifdef HAVE_MPFR - if (m->flags & MPFN) + if ((m->flags & MPFN) != 0) print_func(fp, "%s", mpg_fmt("%R*g", ROUND_MODE, m->mpg_numbr)); - else if (m->flags & MPZN) + else if ((m->flags & MPZN) != 0) print_func(fp, "%s", mpg_fmt("%Zd", m->mpg_i)); else #endif @@ -3667,9 +3667,9 @@ print_memory(NODE *m, NODE *func, Func_print print_func, FILE *fp) pp_string_fp(print_func, fp, m->stptr, m->stlen, '"', false); else if ((m->flags & NUMCUR) != 0) { #ifdef HAVE_MPFR - if (m->flags & MPFN) + if ((m->flags & MPFN) != 0) print_func(fp, "%s", mpg_fmt("%R*g", ROUND_MODE, m->mpg_numbr)); - else if (m->flags & MPZN) + else if ((m->flags & MPZN) != 0) print_func(fp, "%s", mpg_fmt("%Zd", m->mpg_i)); else #endif @@ -3873,9 +3873,9 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump) { 0, NULL } }; - if (pc->sub_flags & GSUB) + if ((pc->sub_flags & GSUB) != 0) fname = "gsub"; - else if (pc->sub_flags & GENSUB) + else if ((pc->sub_flags & GENSUB) != 0) fname = "gensub"; print_func(fp, "%s [arg_count = %ld] [sub_flags = %s]\n", fname, pc->expr_count, @@ -3918,7 +3918,7 @@ print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump) /* NB: concat_flag CSVAR only used in grammar, don't display it */ print_func(fp, "[expr_count = %ld] [concat_flag = %s]\n", pc->expr_count, - (pc->concat_flag & CSUBSEP) ? "CSUBSEP" : "0"); + (pc->concat_flag & CSUBSEP) != 0 ? "CSUBSEP" : "0"); break; case Op_rule: diff --git a/doc/ChangeLog b/doc/ChangeLog index 685338b3..34457ad4 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2012-12-09 Arnold D. Robbins <arnold@skeeve.com> + + * awkforai.txt: Changed content to be pointers to the article + to avoid copyright issues. + * gawk.texi: Updated description of awkforai.txt. + 2012-12-07 Arnold D. Robbins <arnold@skeeve.com> * gawk.texi (I/O Functions): Document that fflush() is now part diff --git a/doc/awkforai.txt b/doc/awkforai.txt index 3fca3204..2908da56 100644 --- a/doc/awkforai.txt +++ b/doc/awkforai.txt @@ -1,150 +1,18 @@ -Draft for ACM SIGPLAN Patterns (Language Trends) +Sun Dec 9 11:58:23 IST 2012 +============================ -1996 +The original of this file was a draft of an article written in 1996 by +Ronald P. Lui for an ACM Sigplan publication, explaining why he used +gawk for teaching introductory Artificial Intelligence courses. -Why GAWK for AI? +Since it was not clear as to copying permissions and so on, it has been +removed from the gawk distribution. -Ronald P. Loui +A quick web search shows that this same draft is available at +http://www.cs.wustl.edu/~loui/sigplan and the final article is available +from the ACM: http://dl.acm.org/citation.cfm?id=242908 -Most people are surprised when I tell them what language we use in our -undergraduate AI programming class. That's understandable. We use -GAWK. GAWK, Gnu's version of Aho, Weinberger, and Kernighan's old -pattern scanning language isn't even viewed as a programming language by -most people. Like PERL and TCL, most prefer to view it as a "scripting -language." It has no objects; it is not functional; it does no built-in -logic programming. Their surprise turns to puzzlement when I confide -that (a) while the students are allowed to use any language they want; -(b) with a single exception, the best work consistently results from -those working in GAWK. (footnote: The exception was a PASCAL -programmer who is now an NSF graduate fellow getting a Ph.D. in -mathematics at Harvard.) Programmers in C, C++, and LISP haven't even -been close (we have not seen work in PROLOG or JAVA). +The article itself is recommended reading. -Why GAWK? - -There are some quick answers that have to do with the pragmatics of -undergraduate programming. Then there are more instructive answers that -might be valuable to those who debate programming paradigms or to those -who study the history of AI languages. And there are some deep -philosophical answers that expose the nature of reasoning and symbolic -AI. I think the answers, especially the last ones, can be even more -surprising than the observed effectiveness of GAWK for AI. - -First it must be confessed that PERL programmers can cobble together AI -projects well, too. Most of GAWK's attractiveness is reproduced in -PERL, and the success of PERL forebodes some of the success of GAWK. -Both are powerful string-processing languages that allow the programmer -to exploit many of the features of a UNIX environment. Both provide -powerful constructions for manipulating a wide variety of data in -reasonably efficient ways. Both are interpreted, which can reduce -development time. Both have short learning curves. The GAWK manual can -be consumed in a single lab session and the language can be mastered by -the next morning by the average student. GAWK's automatic -initialization, implicit coercion, I/O support and lack of pointers -forgive many of the mistakes that young programmers are likely to make. -Those who have seen C but not mastered it are happy to see that GAWK -retains some of the same sensibilities while adding what must be -regarded as spoonsful of syntactic sugar. Some will argue that -PERL has superior functionality, but for quick AI applications, the -additional functionality is rarely missed. In fact, PERL's terse syntax -is not friendly when regular expressions begin to proliferate and -strings contain fragments of HTML, WWW addresses, or shell commands. -PERL provides new ways of doing things, but not necessarily ways of -doing new things. - -In the end, despite minor difference, both PERL and GAWK minimize -programmer time. Neither really provides the programmer the setting in -which to worry about minimizing run-time. - -There are further simple answers. Probably the best is the fact that -increasingly, undergraduate AI programming is involving the Web. Oren -Etzioni (University of Washington, Seattle) has for a while been arguing -that the "softbot" is replacing the mechanical engineers' robot as the -most glamorous AI testbed. If the artifact whose behavior needs to be -controlled in an intelligent way is the software agent, then a language -that is well-suited to controlling the software environment is the -appropriate language. That would imply a scripting language. If the -robot is KAREL, then the right language is "turn left; turn right." If -the robot is Netscape, then the right language is something that can -generate "netscape -remote 'openURL(http://cs.wustl.edu/~loui)'" with -elan. - -Of course, there are deeper answers. Jon Bentley found two pearls in -GAWK: its regular expressions and its associative arrays. GAWK asks -the programmer to use the file system for data organization and the -operating system for debugging tools and subroutine libraries. There is -no issue of user-interface. This forces the programmer to return to the -question of what the program does, not how it looks. There is no time -spent programming a binsort when the data can be shipped to /bin/sort -in no time. (footnote: I am reminded of my IBM colleague Ben Grosof's -advice for Palo Alto: Don't worry about whether it's highway 101 or 280. -Don't worry if you have to head south for an entrance to go north. Just -get on the highway as quickly as possible.) - -There are some similarities between GAWK and LISP that are illuminating. -Both provided a powerful uniform data structure (the associative array -implemented as a hash table for GAWK and the S-expression, or list of -lists, for LISP). Both were well-supported in their environments (GAWK -being a child of UNIX, and LISP being the heart of lisp machines). Both -have trivial syntax and find their power in the programmer's willingness -to use the simple blocks to build a complex approach. - -Deeper still, is the nature of AI programming. AI is about -functionality and exploratory programming. It is about bottom-up design -and the building of ambitions as greater behaviors can be demonstrated. -Woe be to the top-down AI programmer who finds that the bottom-level -refinements, "this subroutine parses the sentence," cannot actually be -implemented. Woe be to the programmer who perfects the data structures -for that heapsort when the whole approach to the high-level problem -needs to be rethought, and the code is sent to the junkheap the next day. - -AI programming requires high-level thinking. There have always been a few -gifted programmers who can write high-level programs in assembly language. -Most however need the ambient abstraction to have a higher floor. - -Now for the surprising philosophical answers. First, AI has discovered -that brute-force combinatorics, as an approach to generating intelligent -behavior, does not often provide the solution. Chess, neural nets, and -genetic programming show the limits of brute computation. The -alternative is clever program organization. (footnote: One might add -that the former are the AI approaches that work, but that is easily -dismissed: those are the AI approaches that work in general, precisely -because cleverness is problem-specific.) So AI programmers always want -to maximize the content of their program, not optimize the efficiency -of an approach. They want minds, not insects. Instead of enumerating -large search spaces, they define ways of reducing search, ways of -bringing different knowledge to the task. A language that maximizes -what the programmer can attempt rather than one that provides tremendous -control over how to attempt it, will be the AI choice in the end. - -Second, inference is merely the expansion of notation. No matter whether -the logic that underlies an AI program is fuzzy, probabilistic, deontic, -defeasible, or deductive, the logic merely defines how strings can be -transformed into other strings. A language that provides the best -support for string processing in the end provides the best support for -logic, for the exploration of various logics, and for most forms of -symbolic processing that AI might choose to call "reasoning" instead of -"logic." The implication is that PROLOG, which saves the AI programmer -from having to write a unifier, saves perhaps two dozen lines of GAWK -code at the expense of strongly biasing the logic and representational -expressiveness of any approach. - -I view these last two points as news not only to the programming language -community, but also to much of the AI community that has not reflected on -the past decade's lessons. - -In the puny language, GAWK, which Aho, Weinberger, and Kernighan thought -not much more important than grep or sed, I find lessons in AI's trends, -AI's history, and the foundations of AI. What I have found not only -surprising but also hopeful, is that when I have approached the AI -people who still enjoy programming, some of them are not the least bit -surprised. - - -R. Loui (loui@ai.wustl.edu) is Associate Professor of Computer Science, -at Washington University in St. Louis. He has published in AI Journal, -Computational Intelligence, ACM SIGART, AI Magazine, AI and Law, the ACM -Computing Surveys Symposium on AI, Cognitive Science, Minds and -Machines, Journal of Philosophy, and is on this year's program -committees for AAAI (National AI conference) and KR (Knowledge -Representation and Reasoning). +Arnold Robbins +arnold@skeeve.com diff --git a/doc/gawk.info b/doc/gawk.info index 09f30433..2e542fd9 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -21829,16 +21829,14 @@ operations: in `gawkapi.h'. For correct use, you must therefore include the corresponding standard header file _before_ including `gawkapi.h': - C Entity Header File - ----------------------------- - `FILE' `<stdio.h>' - `NULL' `<stddef.h>' - `malloc()' `<stdlib.h>' - `memset()',`<string.h>' - `memcpy()' - `size_t' `<sys/types.h>' - `struct `<sys/stat.h>' - stat' + C Entity Header File + ------------------------------------------- + `FILE' `<stdio.h>' + `NULL' `<stddef.h>' + `malloc()' `<stdlib.h>' + `memset()', `memcpy()' `<string.h>' + `size_t' `<sys/types.h>' + `struct stat' `<sys/stat.h>' Due to portability concerns, especially to systems that are not fully standards-compliant, it is your responsibility to include @@ -22185,12 +22183,19 @@ Extension functions are described by the following record: The name of the new function. `awk' level code calls the function by this name. This is a regular C string. + Function names must obey the rules for `awk' identifiers. That is, + they must begin with either a letter or an underscore, which may + be followed by any number of letters, digits, and underscores. + `awk_value_t *(*function)(int num_actual_args, awk_value_t *result);' This is a pointer to the C function that provides the desired functionality. The function must fill in the result with either a number or a string. `awk' takes ownership of any string memory. As mentioned earlier, string memory *must* come from `malloc()'. + The `num_actual_args' argument tells the C function how many + actual parameters were passed from the calling `awk' code. + The function must return the value of `result'. This is for the convenience of the calling code inside `gawk'. @@ -25564,8 +25569,9 @@ Various `.c', `.y', and `.h' files does not. `doc/awkforai.txt' - A short article describing why `gawk' is a good language for - Artificial Intelligence (AI) programming. + Pointers to the original draft of a short article describing why + `gawk' is a good language for Artificial Intelligence (AI) + programming. `doc/bc_notes' A brief description of `gawk''s "byte code" internals. @@ -31579,7 +31585,7 @@ Index * testbits.awk program: Bitwise Functions. (line 70) * Texinfo <1>: Adding Code. (line 99) * Texinfo <2>: Distribution contents. - (line 79) + (line 80) * Texinfo <3>: Extract Program. (line 12) * Texinfo <4>: Dupword Program. (line 17) * Texinfo <5>: Library Functions. (line 22) @@ -32726,6 +32732,7 @@ Ref: call-new-function876677 Node: Extension Future Growth878671 Node: Extension API Description879489 Node: Extension API Functions Introduction880817 +<<<<<<< HEAD Node: General Data Types885517 Ref: General Data Types-Footnote-1891119 Node: Requesting Values891418 @@ -32840,5 +32847,120 @@ Node: Copying1120790 Node: GNU Free Documentation License1158347 Node: Index1183484 >>>>>>> master +======= +Node: General Data Types885595 +Ref: General Data Types-Footnote-1891197 +Node: Requesting Values891496 +Ref: table-value-types-returned892227 +Node: Constructor Functions893181 +Node: Registration Functions896177 +Node: Extension Functions896862 +Node: Exit Callback Functions899036 +Node: Extension Version String900279 +Node: Input Parsers900929 +Node: Output Wrappers909516 +Node: Two-way processors913932 +Node: Printing Messages916062 +Ref: Printing Messages-Footnote-1917139 +Node: Updating `ERRNO'917291 +Node: Accessing Parameters918030 +Node: Symbol Table Access919260 +Node: Symbol table by name919772 +Ref: Symbol table by name-Footnote-1921942 +Node: Symbol table by cookie922022 +Ref: Symbol table by cookie-Footnote-1926151 +Node: Cached values926214 +Ref: Cached values-Footnote-1929657 +Node: Array Manipulation929748 +Ref: Array Manipulation-Footnote-1930846 +Node: Array Data Types930885 +Ref: Array Data Types-Footnote-1933588 +Node: Array Functions933680 +Node: Flattening Arrays937446 +Node: Creating Arrays944279 +Node: Extension API Variables949074 +Node: Extension Versioning949710 +Node: Extension API Informational Variables951611 +Node: Extension API Boilerplate952697 +Node: Finding Extensions956528 +Node: Extension Example957075 +Node: Internal File Description957813 +Node: Internal File Ops961501 +Ref: Internal File Ops-Footnote-1972948 +Node: Using Internal File Ops973088 +Ref: Using Internal File Ops-Footnote-1975441 +Node: Extension Samples975707 +Node: Extension Sample File Functions977150 +Node: Extension Sample Fnmatch985623 +Node: Extension Sample Fork987349 +Node: Extension Sample Ord988563 +Node: Extension Sample Readdir989339 +Node: Extension Sample Revout990843 +Node: Extension Sample Rev2way991436 +Node: Extension Sample Read write array992126 +Node: Extension Sample Readfile994009 +Node: Extension Sample API Tests994764 +Node: Extension Sample Time995289 +Node: gawkextlib996596 +Node: Language History998977 +Node: V7/SVR3.11000499 +Node: SVR41002820 +Node: POSIX1004262 +Node: BTL1005270 +Node: POSIX/GNU1006075 +Node: Common Extensions1011610 +Node: Ranges and Locales1012669 +Ref: Ranges and Locales-Footnote-11017287 +Ref: Ranges and Locales-Footnote-21017314 +Ref: Ranges and Locales-Footnote-31017574 +Node: Contributors1017795 +Node: Installation1022091 +Node: Gawk Distribution1022985 +Node: Getting1023469 +Node: Extracting1024295 +Node: Distribution contents1025987 +Node: Unix Installation1031248 +Node: Quick Installation1031865 +Node: Additional Configuration Options1033827 +Node: Configuration Philosophy1035304 +Node: Non-Unix Installation1037646 +Node: PC Installation1038104 +Node: PC Binary Installation1039403 +Node: PC Compiling1041251 +Node: PC Testing1044195 +Node: PC Using1045371 +Node: Cygwin1049556 +Node: MSYS1050556 +Node: VMS Installation1051070 +Node: VMS Compilation1051673 +Ref: VMS Compilation-Footnote-11052680 +Node: VMS Installation Details1052738 +Node: VMS Running1054373 +Node: VMS Old Gawk1055980 +Node: Bugs1056454 +Node: Other Versions1060306 +Node: Notes1065621 +Node: Compatibility Mode1066280 +Node: Additions1067063 +Node: Accessing The Source1067990 +Node: Adding Code1069593 +Node: New Ports1075635 +Node: Derived Files1079770 +Ref: Derived Files-Footnote-11085078 +Ref: Derived Files-Footnote-21085112 +Ref: Derived Files-Footnote-31085712 +Node: Future Extensions1085810 +Node: Implementation Limitations1086391 +Node: Basic Concepts1087618 +Node: Basic High Level1088299 +Ref: figure-general-flow1088570 +Ref: figure-process-flow1089169 +Ref: Basic High Level-Footnote-11092398 +Node: Basic Data Typing1092583 +Node: Glossary1095938 +Node: Copying1121249 +Node: GNU Free Documentation License1158806 +Node: Index1183943 +>>>>>>> master End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 5b6ea931..fca7cebb 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -28722,7 +28722,7 @@ The following types and/or macros and/or functions are referenced in @file{gawkapi.h}. For correct use, you must therefore include the corresponding standard header file @emph{before} including @file{gawkapi.h}: -@multitable {C Entity} {@code{<sys/types.h>}} +@multitable {@code{memset()}, @code{memcpy()}} {@code{<sys/types.h>}} @headitem C Entity @tab Header File @item @code{FILE} @tab @code{<stdio.h>} @item @code{NULL} @tab @code{<stddef.h>} @@ -29110,6 +29110,11 @@ The name of the new function. @command{awk} level code calls the function by this name. This is a regular C string. +Function names must obey the rules for @command{awk} +identifiers. That is, they must begin with either a letter +or an underscore, which may be followed by any number of +letters, digits, and underscores. + @item awk_value_t *(*function)(int num_actual_args, awk_value_t *result); This is a pointer to the C function that provides the desired functionality. @@ -29117,6 +29122,9 @@ The function must fill in the result with either a number or a string. @command{awk} takes ownership of any string memory. As mentioned earlier, string memory @strong{must} come from @code{malloc()}. +The @code{num_actual_args} argument tells the C function how many +actual parameters were passed from the calling @command{awk} code. + The function must return the value of @code{result}. This is for the convenience of the calling code inside @command{gawk}. @@ -33114,7 +33122,8 @@ as a list of things that the POSIX standard should describe but does not. @cindex artificial intelligence@comma{} @command{gawk} and @item doc/awkforai.txt -A short article describing why @command{gawk} is a good language for +Pointers to the original draft of +a short article describing why @command{gawk} is a good language for Artificial Intelligence (AI) programming. @item doc/bc_notes @@ -579,16 +579,16 @@ cmp_nodes(NODE *t1, NODE *t2) if (t1 == t2) return 0; - if (t1->flags & MAYBE_NUM) + if ((t1->flags & MAYBE_NUM) != 0) (void) force_number(t1); - if (t2->flags & MAYBE_NUM) + if ((t2->flags & MAYBE_NUM) != 0) (void) force_number(t2); - if (t1->flags & INTIND) + if ((t1->flags & INTIND) != 0) t1 = force_string(t1); - if (t2->flags & INTIND) + if ((t2->flags & INTIND) != 0) t2 = force_string(t2); - if ((t1->flags & NUMBER) && (t2->flags & NUMBER)) + if ((t1->flags & NUMBER) != 0 && (t2->flags & NUMBER) != 0) return cmp_numbers(t1, t2); (void) force_string(t1); @@ -735,15 +735,15 @@ set_BINMODE() lintwarn(_("`BINMODE' is a gawk extension")); } if (do_traditional) - BINMODE = 0; + BINMODE = TEXT_TRANSLATE; else if ((v->flags & NUMBER) != 0) { (void) force_number(v); BINMODE = get_number_si(v); /* Make sure the value is rational. */ - if (BINMODE < 0) - BINMODE = 0; - else if (BINMODE > 3) - BINMODE = 3; + if (BINMODE < TEXT_TRANSLATE) + BINMODE = TEXT_TRANSLATE; + else if (BINMODE > BINMODE_BOTH) + BINMODE = BINMODE_BOTH; } else if ((v->flags & STRING) != 0) { p = v->stptr; @@ -763,13 +763,13 @@ set_BINMODE() BINMODE = p[0] - '0'; break; case 'r': - BINMODE = 1; + BINMODE = BINMODE_INPUT; break; case 'w': - BINMODE = 2; + BINMODE = BINMODE_OUTPUT; break; default: - BINMODE = 3; + BINMODE = BINMODE_BOTH; goto bad_value; break; } @@ -777,21 +777,21 @@ set_BINMODE() case 2: switch (p[0]) { case 'r': - BINMODE = 3; + BINMODE = BINMODE_BOTH; if (p[1] != 'w') goto bad_value; break; case 'w': - BINMODE = 3; + BINMODE = BINMODE_BOTH; if (p[1] != 'r') goto bad_value; break; + } break; default: bad_value: lintwarn(_("BINMODE value `%s' is invalid, treated as 3"), p); break; - } } } else BINMODE = 3; /* shouldn't happen */ @@ -37,6 +37,42 @@ extern SRCFILE *srcfiles; #include <dlfcn.h> +/* + * is_letter --- function to check letters + * isalpha() isn't good enough since it can look at the locale. + * Underscore counts as a letter in awk identifiers + */ + +static bool +is_letter(unsigned char c) +{ + switch (c) { + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': + case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': + case 's': case 't': case 'u': case 'v': case 'w': case 'x': + case 'y': case 'z': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': + case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': + case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': + case 'Y': case 'Z': + case '_': + return true; + default: + return false; + } +} + +/* is_identifier_char --- return true if a character can be used in an identifier */ + +static bool +is_identifier_char(unsigned char c) +{ + return (is_letter(c) || isdigit(c)); +} + + #define INIT_FUNC "dl_load" /* load_ext --- load an external library */ @@ -184,10 +220,14 @@ make_builtin(const awk_ext_func_t *funcinfo) if (sp == NULL || *sp == '\0') fatal(_("make_builtin: missing function name")); + if (! is_letter(*sp)) + return false; + + sp++; + while ((c = *sp++) != '\0') { - if ((sp == &name[1] && c != '_' && ! isalpha((unsigned char) c)) - || (sp > &name[1] && ! is_identchar((unsigned char) c))) - fatal(_("make_builtin: illegal character `%c' in function name `%s'"), c, name); + if (! is_identifier_char(c)) + return false; } f = lookup(name); @@ -239,7 +279,7 @@ make_old_builtin(const char *name, NODE *(*func)(int), int count) /* temporary * while ((c = *sp++) != '\0') { if ((sp == & name[1] && c != '_' && ! isalpha((unsigned char) c)) - || (sp > &name[1] && ! is_identchar((unsigned char) c))) + || (sp > &name[1] && ! is_identifier_char((unsigned char) c))) fatal(_("extension: illegal character `%c' in function name `%s'"), c, name); } @@ -413,7 +413,7 @@ node_to_awk_value(NODE *node, awk_value_t *val, awk_valtype_t wanted) val->val_type = AWK_NUMBER; (void) force_number(node); - if (node->flags & NUMCUR) { + if ((node->flags & NUMCUR) != 0) { val->num_value = get_number_d(node); ret = true; } @@ -423,7 +423,7 @@ node_to_awk_value(NODE *node, awk_value_t *val, awk_valtype_t wanted) val->val_type = AWK_STRING; (void) force_string(node); - if (node->flags & STRCUR) { + if ((node->flags & STRCUR) != 0) { val->str_value.str = node->stptr; val->str_value.len = node->stlen; ret = true; @@ -431,9 +431,9 @@ node_to_awk_value(NODE *node, awk_value_t *val, awk_valtype_t wanted) break; case AWK_SCALAR: - if (node->flags & NUMBER) { + if ((node->flags & NUMBER) != 0) { val->val_type = AWK_NUMBER; - } else if (node->flags & STRING) { + } else if ((node->flags & STRING) != 0) { val->val_type = AWK_STRING; } else val->val_type = AWK_UNDEFINED; @@ -442,11 +442,11 @@ node_to_awk_value(NODE *node, awk_value_t *val, awk_valtype_t wanted) case AWK_UNDEFINED: /* return true and actual type for request of undefined */ - if (node->flags & NUMBER) { + if ((node->flags & NUMBER) != 0) { val->val_type = AWK_NUMBER; val->num_value = get_number_d(node); ret = true; - } else if (node->flags & STRING) { + } else if ((node->flags & STRING) != 0) { val->val_type = AWK_STRING; val->str_value.str = node->stptr; val->str_value.len = node->stlen; diff --git a/int_array.c b/int_array.c index 02e682f3..769ac9bb 100644 --- a/int_array.c +++ b/int_array.c @@ -494,7 +494,7 @@ int_list(NODE *symbol, NODE *t) for (j = 0; j < b->aicount; j++) { /* index */ num = b->ainum[j]; - if (assoc_kind & AISTR) { + if ((assoc_kind & AISTR) != 0) { sprintf(buf, "%ld", num); subs = make_string(buf, strlen(buf)); subs->numbr = num; @@ -506,7 +506,7 @@ int_list(NODE *symbol, NODE *t) list[k++] = subs; /* value */ - if (assoc_kind & AVALUE) { + if ((assoc_kind & AVALUE) != 0) { r = b->aivalue[j]; if (r->type == Node_val) { if ((assoc_kind & AVNUM) != 0) @@ -290,12 +290,12 @@ binmode(const char *mode) { switch (mode[0]) { case 'r': - if ((BINMODE & 1) != 0) + if ((BINMODE & BINMODE_INPUT) != 0) mode = "rb"; break; case 'w': case 'a': - if ((BINMODE & 2) != 0) + if ((BINMODE & BINMODE_OUTPUT) != 0) mode = (mode[0] == 'w' ? "wb" : "ab"); break; } @@ -733,7 +733,7 @@ redirect(NODE *redir_exp, int redirtype, int *errflg) * we've gotten EOF from a child input pipeline, it's * a good bet that the child has died. So recover it. */ - if ((rp->flag & RED_EOF) && redirtype == redirect_pipein) { + if ((rp->flag & RED_EOF) != 0 && redirtype == redirect_pipein) { if (rp->pid != -1) wait_any(0); } @@ -779,7 +779,7 @@ redirect(NODE *redir_exp, int redirtype, int *errflg) save_rp = rp; while (rp->output.fp == NULL && rp->iop == NULL) { - if (! new_rp && rp->flag & RED_EOF) { + if (! new_rp && (rp->flag & RED_EOF) != 0) { /* * Encountered EOF on file or pipe -- must be cleared * by explicit close() before reading more @@ -1114,7 +1114,7 @@ close_rp(struct redirect *rp, two_way_close_type how) } else if ((rp->flag & (RED_PIPE|RED_WRITE)) == (RED_PIPE|RED_WRITE)) { /* write to pipe */ status = pclose(rp->output.fp); - if ((BINMODE & 1) != 0) + if ((BINMODE & BINMODE_INPUT) != 0) os_setbinmode(fileno(stdin), O_BINARY); rp->output.fp = NULL; @@ -1233,12 +1233,12 @@ flush_io() } for (rp = red_head; rp != NULL; rp = rp->next) /* flush both files and pipes, what the heck */ - if ((rp->flag & RED_WRITE) && rp->output.fp != NULL) { + if ((rp->flag & RED_WRITE) != 0 && rp->output.fp != NULL) { if (rp->output.gawk_fflush(rp->output.fp, rp->output.opaque)) { - if (rp->flag & RED_PIPE) + if ((rp->flag & RED_PIPE) != 0) warning(_("pipe flush of `%s' failed (%s)."), rp->value, strerror(errno)); - else if (rp->flag & RED_TWOWAY) + else if ((rp->flag & RED_TWOWAY) != 0) warning(_("co-process flush of pipe to `%s' failed (%s)."), rp->value, strerror(errno)); else @@ -1697,7 +1697,7 @@ two_way_open(const char *str, struct redirect *rp) if (! no_ptys && pty_vs_pipe(str)) { static bool initialized = false; static char first_pty_letter; -#ifdef HAVE_GRANTPT +#if defined(HAVE_GRANTPT) && ! defined(HAVE_POSIX_OPENPT) static int have_dev_ptmx; #endif char slavenam[32]; @@ -1714,7 +1714,7 @@ two_way_open(const char *str, struct redirect *rp) if (! initialized) { initialized = true; -#ifdef HAVE_GRANTPT +#if defined(HAVE_GRANTPT) && ! defined(HAVE_POSIX_OPENPT) have_dev_ptmx = (stat("/dev/ptmx", & statb) >= 0); #endif i = 0; @@ -1729,8 +1729,13 @@ two_way_open(const char *str, struct redirect *rp) } #ifdef HAVE_GRANTPT +#ifdef HAVE_POSIX_OPENPT + { + master = posix_openpt(O_RDWR|O_NOCTTY); +#else if (have_dev_ptmx) { master = open("/dev/ptmx", O_RDWR); +#endif if (master >= 0) { char *tem; @@ -2255,7 +2260,7 @@ gawk_popen(const char *cmd, struct redirect *rp) os_restore_mode(fileno(stdin)); current = popen(cmd, binmode("r")); - if ((BINMODE & 1) != 0) + if ((BINMODE & BINMODE_INPUT) != 0) os_setbinmode(fileno(stdin), O_BINARY); if (current == NULL) return NULL; @@ -3558,9 +3563,9 @@ pty_vs_pipe(const char *command) return false; val = in_PROCINFO(command, "pty", NULL); if (val) { - if (val->flags & MAYBE_NUM) + if ((val->flags & MAYBE_NUM) != 0) (void) force_number(val); - if (val->flags & NUMBER) + if ((val->flags & NUMBER) != 0) return ! iszero(val); else return (val->stlen != 0); @@ -628,10 +628,10 @@ out: if (preassigns != NULL) efree(preassigns); - if ((BINMODE & 1) != 0) + if ((BINMODE & BINMODE_INPUT) != 0) if (os_setbinmode(fileno(stdin), O_BINARY) == -1) fatal(_("can't set binary mode on stdin (%s)"), strerror(errno)); - if ((BINMODE & 2) != 0) { + if ((BINMODE & BINMODE_OUTPUT) != 0) { if (os_setbinmode(fileno(stdout), O_BINARY) == -1) fatal(_("can't set binary mode on stdout (%s)"), strerror(errno)); if (os_setbinmode(fileno(stderr), O_BINARY) == -1) @@ -349,10 +349,10 @@ mpg_force_number(NODE *n) { unsigned int newflags = 0; - if (is_mpg_number(n) && (n->flags & NUMCUR)) + if (is_mpg_number(n) && (n->flags & NUMCUR) != 0) return n; - if (n->flags & MAYBE_NUM) { + if ((n->flags & MAYBE_NUM) != 0) { n->flags &= ~MAYBE_NUM; newflags = NUMBER; } @@ -528,7 +528,7 @@ set_PREC() return; val = PREC_node->var_value; - if (val->flags & MAYBE_NUM) + if ((val->flags & MAYBE_NUM) != 0) force_number(val); if ((val->flags & (STRING|NUMBER)) == STRING) { @@ -50,7 +50,7 @@ r_force_number(NODE *n) unsigned int newflags; extern double strtod(); - if (n->flags & NUMCUR) + if ((n->flags & NUMCUR) != 0) return n; /* all the conditionals are an attempt to avoid the expensive strtod */ @@ -75,7 +75,7 @@ r_force_number(NODE *n) if (isalpha((unsigned char) *cp)) { return n; } else if (n->stlen == 4 && is_ieee_magic_val(n->stptr)) { - if (n->flags & MAYBE_NUM) + if ((n->flags & MAYBE_NUM) != 0) n->flags &= ~MAYBE_NUM; n->flags |= NUMBER|NUMCUR; n->numbr = get_ieee_magic_val(n->stptr); @@ -101,7 +101,7 @@ r_force_number(NODE *n) return n; } - if (n->flags & MAYBE_NUM) { + if ((n->flags & MAYBE_NUM) != 0) { newflags = NUMBER; n->flags &= ~MAYBE_NUM; } else @@ -245,7 +245,7 @@ r_format_val(const char *format, int index, NODE *s) s->stlen = strlen(sp); } s->stfmt = -1; - if (s->flags & INTIND) { + if ((s->flags & INTIND) != 0) { s->flags &= ~(INTIND|NUMBER); s->flags |= STRING; } @@ -374,7 +374,7 @@ make_str_node(const char *s, size_t len, int flags) r->wstlen = 0; #endif /* MBS_SUPPORT */ - if (flags & ALREADY_MALLOCED) + if ((flags & ALREADY_MALLOCED) != 0) r->stptr = (char *) s; else { emalloc(r->stptr, char *, len + 2, "make_str_node"); @@ -448,7 +448,7 @@ r_unref(NODE *tmp) tmp->valref--; return; } - if (tmp->flags & STRCUR) + if ((tmp->flags & STRCUR) != 0) efree(tmp->stptr); } #else @@ -428,7 +428,7 @@ cleanup: case Op_concat: str = pp_list(pc->expr_count, NULL, - (pc->concat_flag & CSUBSEP) ? ", " : op2str(Op_concat)); + (pc->concat_flag & CSUBSEP) != 0 ? ", " : op2str(Op_concat)); pp_push(Op_concat, str, CAN_FREE); break; @@ -499,9 +499,9 @@ cleanup: case Op_sub_builtin: { const char *fname = "sub"; - if (pc->sub_flags & GSUB) + if ((pc->sub_flags & GSUB) != 0) fname = "gsub"; - else if (pc->sub_flags & GENSUB) + else if ((pc->sub_flags & GENSUB) != 0) fname = "gensub"; tmp = pp_list(pc->expr_count, "()", ", "); str = pp_concat(fname, tmp, ""); @@ -57,7 +57,9 @@ #include <limits.h> /* This header defines the MIN and MAX macros. */ +#ifndef VMS #include <sys/param.h> +#endif /* VMS */ #ifdef GAWK #undef alloca diff --git a/str_array.c b/str_array.c index a38562cd..e5b3b400 100644 --- a/str_array.c +++ b/str_array.c @@ -378,12 +378,12 @@ str_list(NODE *symbol, NODE *t) for (b = symbol->buckets[i]; b != NULL; b = b->ahnext) { /* index */ subs = b->ahname; - if (assoc_kind & AINUM) + if ((assoc_kind & AINUM) != 0) (void) force_number(subs); list[k++] = dupnode(subs); /* value */ - if (assoc_kind & AVALUE) { + if ((assoc_kind & AVALUE) != 0) { val = b->ahvalue; if (val->type == Node_val) { if ((assoc_kind & AVNUM) != 0) diff --git a/vms/ChangeLog b/vms/ChangeLog index 2109f6a3..d8fbf536 100644 --- a/vms/ChangeLog +++ b/vms/ChangeLog @@ -1,3 +1,7 @@ +2012-12-09 Anders Wallin <anders_s_wallin@yahoo.se> + + * vmstest.com: Updated to match main test/Makefile. + 2012-12-02 Arnold D. Robbins <arnold@skeeve.com> * vms_gawk.c (CmdName): Force to just "GAWK". diff --git a/vms/vmstest.com b/vms/vmstest.com index 179ad679..fd8e7ee3 100644 --- a/vms/vmstest.com +++ b/vms/vmstest.com @@ -8,6 +8,10 @@ $ $! 3.1.7: changed to share code among many common tests, and $! to put results for test foo into _foo.tmp instead of tmp. $! +$! 4.0.71: New tests: +$! functab1,functab2,functab3,id,incdupe,incdupe2, incdupe3,include2 +$! symtab1,symtab2,symtab3,symtab4,symtab5,symtab6 +$! $ echo = "write sys$output" $ cmp = "diff/Output=_NL:/Maximum=1" $ igncascmp = "''cmp'/Ignore=Case" @@ -15,12 +19,10 @@ $ sumslp = "edit/Sum" $ rm = "delete/noConfirm/noLog" $ mv = "rename/New_Vers" $ gawk = "$sys$disk:[-]gawk" -$ pgawk = "$sys$disk:[-]pgawk" $ AWKPATH_srcdir = "define/User AWKPATH sys$disk:[]" $ $ listdepth = 0 $ pipeok = 0 -$ pgawkok = -1 $ floatmode = -1 ! 0: D_float, 1: G_float, 2: IEEE T_float $ $ list = p1+" "+p2+" "+p3+" "+p4+" "+p5+" "+p6+" "+p7+" "+p8 @@ -34,7 +36,7 @@ $all: $bigtest: echo "bigtest..." $ ! omits "printlang" and "extra" $ list = "basic unix_tests gawk_ext vms_tests charset_tests" - - + " machine_tests pgawk_tests" + + " machine_tests" $ gosub list_of_tests $ return $ @@ -98,18 +100,20 @@ $gawk_ext: echo "gawk_ext... (gawk.extensions)" $ list = "aadelete1 aadelete2 aarray1 aasort aasorti" - + " argtest arraysort backw badargs beginfile1 binmode1" - + " clos1way charasbytes delsub devfd devfd1 devfd2 dumpvars exit" - - + " fieldwdth fpat1 fpat2 fpat3 fpatnull funlen fsfwfs" - + + " fieldwdth fpat1 fpat2 fpat3 fpatnull funlen functab1" - + + " functab2 functab3 fsfwfs" - + " fwtest fwtest2 fwtest3" - + " gensub gensub2 getlndir gnuops2 gnuops3 gnureops" - - + " icasefs icasers igncdym igncfs ignrcase ignrcas2" + + " icasefs id icasers igncdym igncfs ignrcase ignrcas2 incdupe incdupe2 incdupe3" $ gosub list_of_tests -$ list = "indirectcall lint lintold lintwarn match1" - +$ list = "include2 indirectcall lint lintold lintwarn match1" - + " match2 match3 manyfiles mbprintf3 mbstr1" - + " nastyparm next nondec" - + " nondec2 patsplit posix profile1 procinfs printfbad1" - - + " printfbad2 printfbad3 pty1 regx8bit rebuf reint" - - + " reint2 rsstart1 rsstart2 rsstart3 rstest6 shadow" - - + " sortfor sortu splitarg4 strtonum strftime switch2" + + " printfbad2 printfbad3 profile2 profile3 pty1" - + + " regx8bit rebuf reint reint2 rsstart1 rsstart2 rsstart3 rstest6" - + + " shadow sortfor sortu splitarg4 strtonum strftime switch2" - + + " symtab1 symtab2 symtab3 symtab4 symtab5 symtab6" $ gosub list_of_tests $ return $ @@ -135,16 +139,6 @@ $ list = "double1 double2 fmtspcl intformat" $ gosub list_of_tests $ return $ -$ ! pgawk_tests is part of bigtest; profile_tests is a separate subset -$profile_tests: echo "profile_tests..." -$ list = "profile1" -$ gosub list_of_tests -$ ! fall through to pgawk_tests -$pgawk_tests: echo "pgawk_tests..." -$ list = "profile2 profile3" -$ gosub list_of_tests -$ return -$ $extra: echo "extra..." $ list = "regtest inftest inet" $ gosub list_of_tests @@ -378,15 +372,16 @@ $pty1: $ echo "''test': not supported" $ return $ -$messages: echo "messages" +$ +$messages: echo "''test'" $ set noOn -$ gawk -f messages.awk > out2 >& out3 -$ cmp out1.ok out1. -$ if $status then rm out1.; -$ cmp out2.ok out2. -$ if $status then rm out2.; -$ cmp out3.ok out3. -$ if $status then rm out3.; +$ gawk -f 'test'.awk > _out2 >& _out3 +$ cmp out1.ok _out1. +$ if $status then rm _out1.; +$ cmp out2.ok _out2. +$ if $status then rm _out2.; +$ cmp out3.ok _out3. +$ if $status then rm _out3.; $ set On $ return $ @@ -608,6 +603,67 @@ $ cmp intprec.ok _intprec.tmp $ if $status then rm _intprec.tmp; $ return $ +$incdupe: echo "''test'" +$ set noOn +$ gawk --lint -i inclib -i inclib.awk "BEGIN {print sandwich(""a"", ""b"", ""c"")}" > _'test'.tmp 2>&1 +$ if .not. $status then call exit_code 1 _'test'.tmp +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp;* +$ set On +$ return +$ +$incdupe2: echo "''test'" +$ set noOn +$ gawk --lint -f inclib -f inclib.awk >_'test'.tmp 2>&1 +$ if .not. $status then call exit_code 1 _'test'.tmp +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp;* +$ set On +$ return +$ +$incdupe3: echo "''test'" +$ gawk --lint -f hello -f hello.awk >_'test'.tmp 2>&1 +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp;* +$ return +$ +$include2: echo "''test'" +$ gawk -i inclib "BEGIN {print sandwich(""a"", ""b"", ""c"")}" >_'test'.tmp 2>&1 +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp;* +$ return +$ +$id: +$symtab1: +$symtab2: +$symtab3: echo "''test'" +$ set noOn +$ gawk -f 'test'.awk >_'test'.tmp 2>&1 +$ if .not. $status then call exit_code 2 _'test'.tmp +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp;* +$ set On +$ return +$ +$symtab4: +$symtab5: echo "''test'" +$ set noOn +$ gawk -f 'test'.awk <'test'.in >_'test'.tmp 2>&1 +$ if .not. $status then call exit_code 2 _'test'.tmp +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp;* +$ set On +$ return +$ +$symtab6: echo "''test'" +$ set noOn +$ gawk -d__'test'.tmp -f 'test'.awk +$ pipe search __'test'.tmp "ENVIRON" /match=nand | search sys$pipe "PROCINFO" /match=nand > _'test'.tmp +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp;*,__'test'.tmp;* +$ set On +$ return +$ $childin: echo "childin skipped" $ return $! note: this `childin' test currently [gawk 3.0.3] fails for vms @@ -803,7 +859,9 @@ $aadelete1: $aadelete2: $arrayparm: $fnaryscl: -$match2: +$functab1: +$functab2: +$functab3: $nastyparm: $opasnslf: $opasnidx: @@ -956,7 +1014,6 @@ $aryprm4: $aryprm5: $aryprm6: $aryprm7: -$delfunc: $dfastress: $nfneg: $numindex: @@ -972,8 +1029,9 @@ $ cmp 'test'.ok _'test'.tmp $ if $status then rm _'test'.tmp; $ return $ -$fnamedat: -$fnasgnm: +$ ! +$ ! For tests requiring exit code 2 +$ ! $ echo "''test'" $ set noOn $ gawk -f 'test'.awk <'test'.in >_'test'.tmp 2>&1 @@ -991,8 +1049,11 @@ $ cmp exitval2.ok _exitval2.tmp $ if $status then rm _exitval2.tmp; $ return $ +$delfunc: $fcall_exit2: +$fnamedat: $fnarray2: +$fnasgnm: $fnmisc: $gsubasgn: $unterm: @@ -1050,6 +1111,7 @@ $ $fcall_exit: $fnarray: $funsmnam: +$match2: $paramdup: $paramres: $parseme: @@ -1481,62 +1543,45 @@ $ cmp dumpvars.ok _dumpvars.tmp $ if $status then rm _dumpvars.tmp; $ return $ -$profile1: echo "profile1" -$ ! this profile test is run with gawk rather than pgawk +$profile1: echo "''test'" $ ! FIXME: for both gawk invocations which pipe output to SORT, $ ! two output files get created; the top version has real output $ ! but there's also an empty lower version. -$ oldout = f$search("_profile1.tmp1") -$ gawk --profile -v "sortcmd=SORT sys$intput: sys$output:" - +$ oldout = f$search("_''test'.tmp1") +$ gawk --pretty-print -v "sortcmd=SORT sys$intput: sys$output:" - -f xref.awk dtdgport.awk > _'test'.tmp1 -$ badout = f$search("_profile1.tmp1;-1") +$ badout = f$search("_''test'.tmp1;-1") $ if badout.nes."" .and. badout.nes.oldout then rm 'badout' -$ oldout = f$search("_profile1.tmp2") +$ oldout = f$search("_''test'.tmp2") $ gawk -v "sortcmd=SORT sys$intput: sys$output:" - -f awkprof.out dtdgport.awk > _'test'.tmp2 -$ badout = f$search("_profile1.tmp2;-1") +$ badout = f$search("_''test'.tmp2;-1") $ if badout.nes."" .and. badout.nes.oldout then rm 'badout' -$ cmp _profile1.tmp1 _profile1.tmp2 -$ if $status then rm _profile1.tmp%;,awkprof.out; -$ return -$ -$ ! pgawk tests; building pgawk is optional so have to check whether it's here -$profile2: -$profile3: -$ if pgawkok.lt.0 -$ then f = f$parse(pgawk,".exe;") -$ ! expect first parse to fail due to leading dollar sign -$ if f.eqs."" then f = f$parse(f$extract(1,999,pgawk),".exe;") -$ if f.nes."" then f = f$search(f) -$ pgawkok = (f.nes."").and.1 ! set to 1 or 0 -$ if .not.pgawkok then - - echo "Can't find pgawk.exe so can't run profiling tests." -$ endif -$ if pgawkok then goto do__'test' -$ echo "''test' skipped" +$ cmp _'test'.tmp1 _'test'.tmp2 +$ if $status then rm _'test'.tmp%;,awkprof.out; $ return $ -$do__profile2: echo "profile2" -$ pgawk -v "sortcmd=SORT sys$input: sys$output:" - +$profile2: echo "''test'" +$ gawk --profile -v "sortcmd=SORT sys$input: sys$output:" - -f xref.awk dtdgport.awk > _NL: $ ! sed <awkprof.out 1,2d >_profile2.tmp -$ sumslp awkprof.out /update=sys$input: /output=_profile2.tmp +$ sumslp awkprof.out /update=sys$input: /output=_'test'.tmp -1,2 / $ rm awkprof.out; -$ cmp profile2.ok _profile2.tmp -$ if $status then rm _profile2.tmp;* +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp;* $ return $ -$do__profile3: echo "profile3" -$ pgawk -f profile3.awk > _NL: +$profile3: echo "''test'" +$ gawk --profile -f 'test'.awk > _NL: $ ! sed <awkprof.out 1,2d >_profile3.tmp -$ sumslp awkprof.out /update=sys$input: /output=_profile3.tmp +$ sumslp awkprof.out /update=sys$input: /output=_'test'.tmp -1,2 / $ rm awkprof.out; -$ cmp profile3.ok _profile3.tmp -$ if $status then rm _profile3.tmp;* +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp;* $ return $ $next: echo "next" |