diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | awkgram.c | 303 | ||||
-rw-r--r-- | awkgram.y | 29 | ||||
-rw-r--r-- | doc/ChangeLog | 7 | ||||
-rw-r--r-- | doc/awkcard.in | 10 | ||||
-rw-r--r-- | doc/gawk.info | 605 | ||||
-rw-r--r-- | doc/gawk.texi | 62 | ||||
-rw-r--r-- | test/ChangeLog | 4 | ||||
-rw-r--r-- | test/lintwarn.ok | 2 |
9 files changed, 534 insertions, 498 deletions
@@ -1,3 +1,13 @@ +2012-09-23 Arnold D. Robbins <arnold@skeeve.com> + + `delete array' and `nextfile' are now in POSIX. + Thanks to Nathan Weeks <weeks@iastate.edu> for the + initiative and letting us know about it. + + * awkgram.y: Make the right code changes for `delete array' + and `nextfile'. + (tokentab): Set flags to zero for nextfile. + 2012-09-19 Arnold D. Robbins <arnold@skeeve.com> * symbol.c (load_symbols): Zero out the new node. Prevents assertion @@ -732,20 +732,20 @@ static const yytype_uint16 yyrline[] = 284, 310, 321, 332, 338, 347, 357, 359, 361, 367, 372, 373, 377, 396, 395, 429, 431, 436, 437, 450, 455, 456, 460, 462, 464, 471, 561, 603, 645, 758, - 765, 772, 782, 791, 800, 809, 824, 840, 839, 863, - 875, 875, 973, 973, 998, 1021, 1027, 1028, 1034, 1035, - 1042, 1047, 1059, 1073, 1075, 1083, 1088, 1090, 1098, 1100, - 1109, 1110, 1118, 1123, 1123, 1134, 1138, 1146, 1147, 1150, - 1152, 1157, 1158, 1167, 1168, 1173, 1178, 1184, 1186, 1188, - 1195, 1196, 1202, 1203, 1208, 1210, 1215, 1217, 1219, 1221, - 1227, 1234, 1236, 1238, 1254, 1264, 1271, 1273, 1278, 1280, - 1282, 1290, 1292, 1297, 1299, 1304, 1306, 1308, 1358, 1360, - 1362, 1364, 1366, 1368, 1370, 1372, 1395, 1400, 1405, 1430, - 1436, 1438, 1440, 1442, 1444, 1446, 1451, 1455, 1487, 1489, - 1495, 1501, 1514, 1515, 1516, 1521, 1526, 1530, 1534, 1549, - 1562, 1567, 1603, 1621, 1622, 1628, 1629, 1634, 1636, 1643, - 1660, 1677, 1679, 1686, 1691, 1699, 1709, 1721, 1730, 1734, - 1738, 1742, 1746, 1750, 1753, 1755, 1759, 1763, 1767 + 765, 772, 782, 791, 800, 809, 820, 836, 835, 859, + 871, 871, 969, 969, 995, 1018, 1024, 1025, 1031, 1032, + 1039, 1044, 1056, 1070, 1072, 1080, 1085, 1087, 1095, 1097, + 1106, 1107, 1115, 1120, 1120, 1131, 1135, 1143, 1144, 1147, + 1149, 1154, 1155, 1164, 1165, 1170, 1175, 1181, 1183, 1185, + 1192, 1193, 1199, 1200, 1205, 1207, 1212, 1214, 1216, 1218, + 1224, 1231, 1233, 1235, 1251, 1261, 1268, 1270, 1275, 1277, + 1279, 1287, 1289, 1294, 1296, 1301, 1303, 1305, 1355, 1357, + 1359, 1361, 1363, 1365, 1367, 1369, 1392, 1397, 1402, 1427, + 1433, 1435, 1437, 1439, 1441, 1443, 1448, 1452, 1484, 1486, + 1492, 1498, 1511, 1512, 1513, 1518, 1523, 1527, 1531, 1546, + 1559, 1564, 1600, 1618, 1619, 1625, 1626, 1631, 1633, 1640, + 1657, 1674, 1676, 1683, 1688, 1696, 1706, 1718, 1727, 1731, + 1735, 1739, 1743, 1747, 1750, 1752, 1756, 1760, 1764 }; #endif @@ -2804,10 +2804,6 @@ regular_loop: /* Line 1787 of yacc.c */ #line 810 "awkgram.y" { - if (do_traditional) - error_ln((yyvsp[(1) - (2)])->source_line, - _("`nextfile' is a gawk extension")); - /* if inside function (rule = 0), resolve context at run-time */ if (rule == BEGIN || rule == END || rule == ENDFILE) error_ln((yyvsp[(1) - (2)])->source_line, @@ -2821,7 +2817,7 @@ regular_loop: case 56: /* Line 1787 of yacc.c */ -#line 825 "awkgram.y" +#line 821 "awkgram.y" { /* Initialize the two possible jump targets, the actual target * is resolved at run-time. @@ -2840,7 +2836,7 @@ regular_loop: case 57: /* Line 1787 of yacc.c */ -#line 840 "awkgram.y" +#line 836 "awkgram.y" { if (! in_function) yyerror(_("`return' used outside function context")); @@ -2849,7 +2845,7 @@ regular_loop: case 58: /* Line 1787 of yacc.c */ -#line 843 "awkgram.y" +#line 839 "awkgram.y" { if ((yyvsp[(3) - (4)]) == NULL) { (yyval) = list_create((yyvsp[(1) - (4)])); @@ -2874,13 +2870,13 @@ regular_loop: case 60: /* Line 1787 of yacc.c */ -#line 875 "awkgram.y" +#line 871 "awkgram.y" { in_print = true; in_parens = 0; } break; case 61: /* Line 1787 of yacc.c */ -#line 876 "awkgram.y" +#line 872 "awkgram.y" { /* * Optimization: plain `print' has no expression list, so $3 is null. @@ -2981,13 +2977,13 @@ regular_print: case 62: /* Line 1787 of yacc.c */ -#line 973 "awkgram.y" +#line 969 "awkgram.y" { sub_counter = 0; } break; case 63: /* Line 1787 of yacc.c */ -#line 974 "awkgram.y" +#line 970 "awkgram.y" { char *arr = (yyvsp[(2) - (4)])->lextok; @@ -2995,16 +2991,17 @@ regular_print: (yyvsp[(2) - (4)])->memory = variable((yyvsp[(2) - (4)])->source_line, arr, Node_var_new); if ((yyvsp[(4) - (4)]) == NULL) { - static bool warned = false; - - if (do_lint && ! warned) { - warned = true; - lintwarn_ln((yyvsp[(1) - (4)])->source_line, - _("`delete array' is a gawk extension")); - } - if (do_traditional) - error_ln((yyvsp[(1) - (4)])->source_line, - _("`delete array' is a gawk extension")); + /* + * As of September 2012, POSIX has added support + * for `delete array'. See: + * http://austingroupbugs.net/view.php?id=544 + * + * Thanks to Nathan Weeks for the initiative. + * + * Thus we no longer warn or check do_posix. + * Also, since BWK awk supports it, we don't have to + * check do_traditional either. + */ (yyvsp[(1) - (4)])->expr_count = 0; (yyval) = list_append(list_create((yyvsp[(2) - (4)])), (yyvsp[(1) - (4)])); } else { @@ -3016,7 +3013,7 @@ regular_print: case 64: /* Line 1787 of yacc.c */ -#line 1003 "awkgram.y" +#line 1000 "awkgram.y" { static bool warned = false; char *arr = (yyvsp[(3) - (4)])->lextok; @@ -3028,7 +3025,7 @@ regular_print: } if (do_traditional) { error_ln((yyvsp[(1) - (4)])->source_line, - _("`delete array' is a gawk extension")); + _("`delete(array)' is a non-portable tawk extension")); } (yyvsp[(3) - (4)])->memory = variable((yyvsp[(3) - (4)])->source_line, arr, Node_var_new); (yyvsp[(3) - (4)])->opcode = Op_push_array; @@ -3039,31 +3036,31 @@ regular_print: case 65: /* Line 1787 of yacc.c */ -#line 1022 "awkgram.y" +#line 1019 "awkgram.y" { (yyval) = optimize_assignment((yyvsp[(1) - (1)])); } break; case 66: /* Line 1787 of yacc.c */ -#line 1027 "awkgram.y" +#line 1024 "awkgram.y" { (yyval) = NULL; } break; case 67: /* Line 1787 of yacc.c */ -#line 1029 "awkgram.y" +#line 1026 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 68: /* Line 1787 of yacc.c */ -#line 1034 "awkgram.y" +#line 1031 "awkgram.y" { (yyval) = NULL; } break; case 69: /* Line 1787 of yacc.c */ -#line 1036 "awkgram.y" +#line 1033 "awkgram.y" { if ((yyvsp[(1) - (2)]) == NULL) (yyval) = list_create((yyvsp[(2) - (2)])); @@ -3074,13 +3071,13 @@ regular_print: case 70: /* Line 1787 of yacc.c */ -#line 1043 "awkgram.y" +#line 1040 "awkgram.y" { (yyval) = NULL; } break; case 71: /* Line 1787 of yacc.c */ -#line 1048 "awkgram.y" +#line 1045 "awkgram.y" { INSTRUCTION *casestmt = (yyvsp[(5) - (5)]); if ((yyvsp[(5) - (5)]) == NULL) @@ -3096,7 +3093,7 @@ regular_print: case 72: /* Line 1787 of yacc.c */ -#line 1060 "awkgram.y" +#line 1057 "awkgram.y" { INSTRUCTION *casestmt = (yyvsp[(4) - (4)]); if ((yyvsp[(4) - (4)]) == NULL) @@ -3111,13 +3108,13 @@ regular_print: case 73: /* Line 1787 of yacc.c */ -#line 1074 "awkgram.y" +#line 1071 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 74: /* Line 1787 of yacc.c */ -#line 1076 "awkgram.y" +#line 1073 "awkgram.y" { NODE *n = (yyvsp[(2) - (2)])->memory; (void) force_number(n); @@ -3129,7 +3126,7 @@ regular_print: case 75: /* Line 1787 of yacc.c */ -#line 1084 "awkgram.y" +#line 1081 "awkgram.y" { bcfree((yyvsp[(1) - (2)])); (yyval) = (yyvsp[(2) - (2)]); @@ -3138,13 +3135,13 @@ regular_print: case 76: /* Line 1787 of yacc.c */ -#line 1089 "awkgram.y" +#line 1086 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 77: /* Line 1787 of yacc.c */ -#line 1091 "awkgram.y" +#line 1088 "awkgram.y" { (yyvsp[(1) - (1)])->opcode = Op_push_re; (yyval) = (yyvsp[(1) - (1)]); @@ -3153,19 +3150,19 @@ regular_print: case 78: /* Line 1787 of yacc.c */ -#line 1099 "awkgram.y" +#line 1096 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 79: /* Line 1787 of yacc.c */ -#line 1101 "awkgram.y" +#line 1098 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 81: /* Line 1787 of yacc.c */ -#line 1111 "awkgram.y" +#line 1108 "awkgram.y" { (yyval) = (yyvsp[(2) - (3)]); } @@ -3173,7 +3170,7 @@ regular_print: case 82: /* Line 1787 of yacc.c */ -#line 1118 "awkgram.y" +#line 1115 "awkgram.y" { in_print = false; in_parens = 0; @@ -3183,13 +3180,13 @@ regular_print: case 83: /* Line 1787 of yacc.c */ -#line 1123 "awkgram.y" +#line 1120 "awkgram.y" { in_print = false; in_parens = 0; } break; case 84: /* Line 1787 of yacc.c */ -#line 1124 "awkgram.y" +#line 1121 "awkgram.y" { if ((yyvsp[(1) - (3)])->redir_type == redirect_twoway && (yyvsp[(3) - (3)])->lasti->opcode == Op_K_getline_redir @@ -3201,7 +3198,7 @@ regular_print: case 85: /* Line 1787 of yacc.c */ -#line 1135 "awkgram.y" +#line 1132 "awkgram.y" { (yyval) = mk_condition((yyvsp[(3) - (6)]), (yyvsp[(1) - (6)]), (yyvsp[(6) - (6)]), NULL, NULL); } @@ -3209,7 +3206,7 @@ regular_print: case 86: /* Line 1787 of yacc.c */ -#line 1140 "awkgram.y" +#line 1137 "awkgram.y" { (yyval) = mk_condition((yyvsp[(3) - (9)]), (yyvsp[(1) - (9)]), (yyvsp[(6) - (9)]), (yyvsp[(7) - (9)]), (yyvsp[(9) - (9)])); } @@ -3217,13 +3214,13 @@ regular_print: case 91: /* Line 1787 of yacc.c */ -#line 1157 "awkgram.y" +#line 1154 "awkgram.y" { (yyval) = NULL; } break; case 92: /* Line 1787 of yacc.c */ -#line 1159 "awkgram.y" +#line 1156 "awkgram.y" { bcfree((yyvsp[(1) - (2)])); (yyval) = (yyvsp[(2) - (2)]); @@ -3232,19 +3229,19 @@ regular_print: case 93: /* Line 1787 of yacc.c */ -#line 1167 "awkgram.y" +#line 1164 "awkgram.y" { (yyval) = NULL; } break; case 94: /* Line 1787 of yacc.c */ -#line 1169 "awkgram.y" +#line 1166 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]) ; } break; case 95: /* Line 1787 of yacc.c */ -#line 1174 "awkgram.y" +#line 1171 "awkgram.y" { (yyvsp[(1) - (1)])->param_count = 0; (yyval) = list_create((yyvsp[(1) - (1)])); @@ -3253,7 +3250,7 @@ regular_print: case 96: /* Line 1787 of yacc.c */ -#line 1179 "awkgram.y" +#line 1176 "awkgram.y" { (yyvsp[(3) - (3)])->param_count = (yyvsp[(1) - (3)])->lasti->param_count + 1; (yyval) = list_append((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); @@ -3263,55 +3260,55 @@ regular_print: case 97: /* Line 1787 of yacc.c */ -#line 1185 "awkgram.y" +#line 1182 "awkgram.y" { (yyval) = NULL; } break; case 98: /* Line 1787 of yacc.c */ -#line 1187 "awkgram.y" +#line 1184 "awkgram.y" { (yyval) = (yyvsp[(1) - (2)]); } break; case 99: /* Line 1787 of yacc.c */ -#line 1189 "awkgram.y" +#line 1186 "awkgram.y" { (yyval) = (yyvsp[(1) - (3)]); } break; case 100: /* Line 1787 of yacc.c */ -#line 1195 "awkgram.y" +#line 1192 "awkgram.y" { (yyval) = NULL; } break; case 101: /* Line 1787 of yacc.c */ -#line 1197 "awkgram.y" +#line 1194 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 102: /* Line 1787 of yacc.c */ -#line 1202 "awkgram.y" +#line 1199 "awkgram.y" { (yyval) = NULL; } break; case 103: /* Line 1787 of yacc.c */ -#line 1204 "awkgram.y" +#line 1201 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 104: /* Line 1787 of yacc.c */ -#line 1209 "awkgram.y" +#line 1206 "awkgram.y" { (yyval) = mk_expression_list(NULL, (yyvsp[(1) - (1)])); } break; case 105: /* Line 1787 of yacc.c */ -#line 1211 "awkgram.y" +#line 1208 "awkgram.y" { (yyval) = mk_expression_list((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); yyerrok; @@ -3320,31 +3317,31 @@ regular_print: case 106: /* Line 1787 of yacc.c */ -#line 1216 "awkgram.y" +#line 1213 "awkgram.y" { (yyval) = NULL; } break; case 107: /* Line 1787 of yacc.c */ -#line 1218 "awkgram.y" +#line 1215 "awkgram.y" { (yyval) = NULL; } break; case 108: /* Line 1787 of yacc.c */ -#line 1220 "awkgram.y" +#line 1217 "awkgram.y" { (yyval) = NULL; } break; case 109: /* Line 1787 of yacc.c */ -#line 1222 "awkgram.y" +#line 1219 "awkgram.y" { (yyval) = NULL; } break; case 110: /* Line 1787 of yacc.c */ -#line 1228 "awkgram.y" +#line 1225 "awkgram.y" { if (do_lint && (yyvsp[(3) - (3)])->lasti->opcode == Op_match_rec) lintwarn_ln((yyvsp[(2) - (3)])->source_line, @@ -3355,19 +3352,19 @@ regular_print: case 111: /* Line 1787 of yacc.c */ -#line 1235 "awkgram.y" +#line 1232 "awkgram.y" { (yyval) = mk_boolean((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 112: /* Line 1787 of yacc.c */ -#line 1237 "awkgram.y" +#line 1234 "awkgram.y" { (yyval) = mk_boolean((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 113: /* Line 1787 of yacc.c */ -#line 1239 "awkgram.y" +#line 1236 "awkgram.y" { if ((yyvsp[(1) - (3)])->lasti->opcode == Op_match_rec) warning_ln((yyvsp[(2) - (3)])->source_line, @@ -3387,7 +3384,7 @@ regular_print: case 114: /* Line 1787 of yacc.c */ -#line 1255 "awkgram.y" +#line 1252 "awkgram.y" { if (do_lint_old) warning_ln((yyvsp[(2) - (3)])->source_line, @@ -3401,7 +3398,7 @@ regular_print: case 115: /* Line 1787 of yacc.c */ -#line 1265 "awkgram.y" +#line 1262 "awkgram.y" { if (do_lint && (yyvsp[(3) - (3)])->lasti->opcode == Op_match_rec) lintwarn_ln((yyvsp[(2) - (3)])->source_line, @@ -3412,31 +3409,31 @@ regular_print: case 116: /* Line 1787 of yacc.c */ -#line 1272 "awkgram.y" +#line 1269 "awkgram.y" { (yyval) = mk_condition((yyvsp[(1) - (5)]), (yyvsp[(2) - (5)]), (yyvsp[(3) - (5)]), (yyvsp[(4) - (5)]), (yyvsp[(5) - (5)])); } break; case 117: /* Line 1787 of yacc.c */ -#line 1274 "awkgram.y" +#line 1271 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 118: /* Line 1787 of yacc.c */ -#line 1279 "awkgram.y" +#line 1276 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 119: /* Line 1787 of yacc.c */ -#line 1281 "awkgram.y" +#line 1278 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 120: /* Line 1787 of yacc.c */ -#line 1283 "awkgram.y" +#line 1280 "awkgram.y" { (yyvsp[(2) - (2)])->opcode = Op_assign_quotient; (yyval) = (yyvsp[(2) - (2)]); @@ -3445,43 +3442,43 @@ regular_print: case 121: /* Line 1787 of yacc.c */ -#line 1291 "awkgram.y" +#line 1288 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 122: /* Line 1787 of yacc.c */ -#line 1293 "awkgram.y" +#line 1290 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 123: /* Line 1787 of yacc.c */ -#line 1298 "awkgram.y" +#line 1295 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 124: /* Line 1787 of yacc.c */ -#line 1300 "awkgram.y" +#line 1297 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 125: /* Line 1787 of yacc.c */ -#line 1305 "awkgram.y" +#line 1302 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 126: /* Line 1787 of yacc.c */ -#line 1307 "awkgram.y" +#line 1304 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 127: /* Line 1787 of yacc.c */ -#line 1309 "awkgram.y" +#line 1306 "awkgram.y" { int count = 2; bool is_simple_var = false; @@ -3532,43 +3529,43 @@ regular_print: case 129: /* Line 1787 of yacc.c */ -#line 1361 "awkgram.y" +#line 1358 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 130: /* Line 1787 of yacc.c */ -#line 1363 "awkgram.y" +#line 1360 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 131: /* Line 1787 of yacc.c */ -#line 1365 "awkgram.y" +#line 1362 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 132: /* Line 1787 of yacc.c */ -#line 1367 "awkgram.y" +#line 1364 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 133: /* Line 1787 of yacc.c */ -#line 1369 "awkgram.y" +#line 1366 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 134: /* Line 1787 of yacc.c */ -#line 1371 "awkgram.y" +#line 1368 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 135: /* Line 1787 of yacc.c */ -#line 1373 "awkgram.y" +#line 1370 "awkgram.y" { /* * In BEGINFILE/ENDFILE, allow `getline var < file' @@ -3595,7 +3592,7 @@ regular_print: case 136: /* Line 1787 of yacc.c */ -#line 1396 "awkgram.y" +#line 1393 "awkgram.y" { (yyvsp[(2) - (2)])->opcode = Op_postincrement; (yyval) = mk_assignment((yyvsp[(1) - (2)]), NULL, (yyvsp[(2) - (2)])); @@ -3604,7 +3601,7 @@ regular_print: case 137: /* Line 1787 of yacc.c */ -#line 1401 "awkgram.y" +#line 1398 "awkgram.y" { (yyvsp[(2) - (2)])->opcode = Op_postdecrement; (yyval) = mk_assignment((yyvsp[(1) - (2)]), NULL, (yyvsp[(2) - (2)])); @@ -3613,7 +3610,7 @@ regular_print: case 138: /* Line 1787 of yacc.c */ -#line 1406 "awkgram.y" +#line 1403 "awkgram.y" { if (do_lint_old) { warning_ln((yyvsp[(4) - (5)])->source_line, @@ -3637,7 +3634,7 @@ regular_print: case 139: /* Line 1787 of yacc.c */ -#line 1431 "awkgram.y" +#line 1428 "awkgram.y" { (yyval) = mk_getline((yyvsp[(3) - (4)]), (yyvsp[(4) - (4)]), (yyvsp[(1) - (4)]), (yyvsp[(2) - (4)])->redir_type); bcfree((yyvsp[(2) - (4)])); @@ -3646,43 +3643,43 @@ regular_print: case 140: /* Line 1787 of yacc.c */ -#line 1437 "awkgram.y" +#line 1434 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 141: /* Line 1787 of yacc.c */ -#line 1439 "awkgram.y" +#line 1436 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 142: /* Line 1787 of yacc.c */ -#line 1441 "awkgram.y" +#line 1438 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 143: /* Line 1787 of yacc.c */ -#line 1443 "awkgram.y" +#line 1440 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 144: /* Line 1787 of yacc.c */ -#line 1445 "awkgram.y" +#line 1442 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 145: /* Line 1787 of yacc.c */ -#line 1447 "awkgram.y" +#line 1444 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 146: /* Line 1787 of yacc.c */ -#line 1452 "awkgram.y" +#line 1449 "awkgram.y" { (yyval) = list_create((yyvsp[(1) - (1)])); } @@ -3690,7 +3687,7 @@ regular_print: case 147: /* Line 1787 of yacc.c */ -#line 1456 "awkgram.y" +#line 1453 "awkgram.y" { if ((yyvsp[(2) - (2)])->opcode == Op_match_rec) { (yyvsp[(2) - (2)])->opcode = Op_nomatch; @@ -3726,13 +3723,13 @@ regular_print: case 148: /* Line 1787 of yacc.c */ -#line 1488 "awkgram.y" +#line 1485 "awkgram.y" { (yyval) = (yyvsp[(2) - (3)]); } break; case 149: /* Line 1787 of yacc.c */ -#line 1490 "awkgram.y" +#line 1487 "awkgram.y" { (yyval) = snode((yyvsp[(3) - (4)]), (yyvsp[(1) - (4)])); if ((yyval) == NULL) @@ -3742,7 +3739,7 @@ regular_print: case 150: /* Line 1787 of yacc.c */ -#line 1496 "awkgram.y" +#line 1493 "awkgram.y" { (yyval) = snode((yyvsp[(3) - (4)]), (yyvsp[(1) - (4)])); if ((yyval) == NULL) @@ -3752,7 +3749,7 @@ regular_print: case 151: /* Line 1787 of yacc.c */ -#line 1502 "awkgram.y" +#line 1499 "awkgram.y" { static bool warned = false; @@ -3769,7 +3766,7 @@ regular_print: case 154: /* Line 1787 of yacc.c */ -#line 1517 "awkgram.y" +#line 1514 "awkgram.y" { (yyvsp[(1) - (2)])->opcode = Op_preincrement; (yyval) = mk_assignment((yyvsp[(2) - (2)]), NULL, (yyvsp[(1) - (2)])); @@ -3778,7 +3775,7 @@ regular_print: case 155: /* Line 1787 of yacc.c */ -#line 1522 "awkgram.y" +#line 1519 "awkgram.y" { (yyvsp[(1) - (2)])->opcode = Op_predecrement; (yyval) = mk_assignment((yyvsp[(2) - (2)]), NULL, (yyvsp[(1) - (2)])); @@ -3787,7 +3784,7 @@ regular_print: case 156: /* Line 1787 of yacc.c */ -#line 1527 "awkgram.y" +#line 1524 "awkgram.y" { (yyval) = list_create((yyvsp[(1) - (1)])); } @@ -3795,7 +3792,7 @@ regular_print: case 157: /* Line 1787 of yacc.c */ -#line 1531 "awkgram.y" +#line 1528 "awkgram.y" { (yyval) = list_create((yyvsp[(1) - (1)])); } @@ -3803,7 +3800,7 @@ regular_print: case 158: /* Line 1787 of yacc.c */ -#line 1535 "awkgram.y" +#line 1532 "awkgram.y" { if ((yyvsp[(2) - (2)])->lasti->opcode == Op_push_i && ((yyvsp[(2) - (2)])->lasti->memory->flags & (STRCUR|STRING)) == 0 @@ -3822,7 +3819,7 @@ regular_print: case 159: /* Line 1787 of yacc.c */ -#line 1550 "awkgram.y" +#line 1547 "awkgram.y" { /* * was: $$ = $2 @@ -3836,7 +3833,7 @@ regular_print: case 160: /* Line 1787 of yacc.c */ -#line 1563 "awkgram.y" +#line 1560 "awkgram.y" { func_use((yyvsp[(1) - (1)])->lasti->func_name, FUNC_USE); (yyval) = (yyvsp[(1) - (1)]); @@ -3845,7 +3842,7 @@ regular_print: case 161: /* Line 1787 of yacc.c */ -#line 1568 "awkgram.y" +#line 1565 "awkgram.y" { /* indirect function call */ INSTRUCTION *f, *t; @@ -3882,7 +3879,7 @@ regular_print: case 162: /* Line 1787 of yacc.c */ -#line 1604 "awkgram.y" +#line 1601 "awkgram.y" { param_sanity((yyvsp[(3) - (4)])); (yyvsp[(1) - (4)])->opcode = Op_func_call; @@ -3900,37 +3897,37 @@ regular_print: case 163: /* Line 1787 of yacc.c */ -#line 1621 "awkgram.y" +#line 1618 "awkgram.y" { (yyval) = NULL; } break; case 164: /* Line 1787 of yacc.c */ -#line 1623 "awkgram.y" +#line 1620 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 165: /* Line 1787 of yacc.c */ -#line 1628 "awkgram.y" +#line 1625 "awkgram.y" { (yyval) = NULL; } break; case 166: /* Line 1787 of yacc.c */ -#line 1630 "awkgram.y" +#line 1627 "awkgram.y" { (yyval) = (yyvsp[(1) - (2)]); } break; case 167: /* Line 1787 of yacc.c */ -#line 1635 "awkgram.y" +#line 1632 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 168: /* Line 1787 of yacc.c */ -#line 1637 "awkgram.y" +#line 1634 "awkgram.y" { (yyval) = list_merge((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); } @@ -3938,7 +3935,7 @@ regular_print: case 169: /* Line 1787 of yacc.c */ -#line 1644 "awkgram.y" +#line 1641 "awkgram.y" { INSTRUCTION *ip = (yyvsp[(1) - (1)])->lasti; int count = ip->sub_count; /* # of SUBSEP-seperated expressions */ @@ -3956,7 +3953,7 @@ regular_print: case 170: /* Line 1787 of yacc.c */ -#line 1661 "awkgram.y" +#line 1658 "awkgram.y" { INSTRUCTION *t = (yyvsp[(2) - (3)]); if ((yyvsp[(2) - (3)]) == NULL) { @@ -3974,13 +3971,13 @@ regular_print: case 171: /* Line 1787 of yacc.c */ -#line 1678 "awkgram.y" +#line 1675 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 172: /* Line 1787 of yacc.c */ -#line 1680 "awkgram.y" +#line 1677 "awkgram.y" { (yyval) = list_merge((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); } @@ -3988,13 +3985,13 @@ regular_print: case 173: /* Line 1787 of yacc.c */ -#line 1687 "awkgram.y" +#line 1684 "awkgram.y" { (yyval) = (yyvsp[(1) - (2)]); } break; case 174: /* Line 1787 of yacc.c */ -#line 1692 "awkgram.y" +#line 1689 "awkgram.y" { char *var_name = (yyvsp[(1) - (1)])->lextok; @@ -4006,7 +4003,7 @@ regular_print: case 175: /* Line 1787 of yacc.c */ -#line 1700 "awkgram.y" +#line 1697 "awkgram.y" { char *arr = (yyvsp[(1) - (2)])->lextok; (yyvsp[(1) - (2)])->memory = variable((yyvsp[(1) - (2)])->source_line, arr, Node_var_new); @@ -4017,7 +4014,7 @@ regular_print: case 176: /* Line 1787 of yacc.c */ -#line 1710 "awkgram.y" +#line 1707 "awkgram.y" { INSTRUCTION *ip = (yyvsp[(1) - (1)])->nexti; if (ip->opcode == Op_push @@ -4033,7 +4030,7 @@ regular_print: case 177: /* Line 1787 of yacc.c */ -#line 1722 "awkgram.y" +#line 1719 "awkgram.y" { (yyval) = list_append((yyvsp[(2) - (3)]), (yyvsp[(1) - (3)])); if ((yyvsp[(3) - (3)]) != NULL) @@ -4043,7 +4040,7 @@ regular_print: case 178: /* Line 1787 of yacc.c */ -#line 1731 "awkgram.y" +#line 1728 "awkgram.y" { (yyvsp[(1) - (1)])->opcode = Op_postincrement; } @@ -4051,7 +4048,7 @@ regular_print: case 179: /* Line 1787 of yacc.c */ -#line 1735 "awkgram.y" +#line 1732 "awkgram.y" { (yyvsp[(1) - (1)])->opcode = Op_postdecrement; } @@ -4059,43 +4056,43 @@ regular_print: case 180: /* Line 1787 of yacc.c */ -#line 1738 "awkgram.y" +#line 1735 "awkgram.y" { (yyval) = NULL; } break; case 182: /* Line 1787 of yacc.c */ -#line 1746 "awkgram.y" +#line 1743 "awkgram.y" { yyerrok; } break; case 183: /* Line 1787 of yacc.c */ -#line 1750 "awkgram.y" +#line 1747 "awkgram.y" { yyerrok; } break; case 186: /* Line 1787 of yacc.c */ -#line 1759 "awkgram.y" +#line 1756 "awkgram.y" { yyerrok; } break; case 187: /* Line 1787 of yacc.c */ -#line 1763 "awkgram.y" +#line 1760 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); yyerrok; } break; case 188: /* Line 1787 of yacc.c */ -#line 1767 "awkgram.y" +#line 1764 "awkgram.y" { yyerrok; } break; /* Line 1787 of yacc.c */ -#line 4111 "awkgram.c" +#line 4108 "awkgram.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -4325,7 +4322,7 @@ yyreturn: /* Line 2048 of yacc.c */ -#line 1769 "awkgram.y" +#line 1766 "awkgram.y" struct token { @@ -4422,7 +4419,7 @@ static const struct token tokentab[] = { {"match", Op_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_match, 0}, {"mktime", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_mktime, 0}, {"next", Op_K_next, LEX_NEXT, 0, 0, 0}, -{"nextfile", Op_K_nextfile, LEX_NEXTFILE, GAWKX, 0, 0}, +{"nextfile", Op_K_nextfile, LEX_NEXTFILE, 0, 0, 0}, {"or", Op_builtin, LEX_BUILTIN, GAWKX, do_or, MPF(or)}, {"patsplit", Op_builtin, LEX_BUILTIN, GAWKX|A(2)|A(3)|A(4), do_patsplit, 0}, {"print", Op_K_print, LEX_PRINT, 0, 0, 0}, @@ -808,10 +808,6 @@ non_compound_stmt } | LEX_NEXTFILE statement_term { - if (do_traditional) - error_ln($1->source_line, - _("`nextfile' is a gawk extension")); - /* if inside function (rule = 0), resolve context at run-time */ if (rule == BEGIN || rule == END || rule == ENDFILE) error_ln($1->source_line, @@ -978,16 +974,17 @@ regular_print: $2->memory = variable($2->source_line, arr, Node_var_new); if ($4 == NULL) { - static bool warned = false; - - if (do_lint && ! warned) { - warned = true; - lintwarn_ln($1->source_line, - _("`delete array' is a gawk extension")); - } - if (do_traditional) - error_ln($1->source_line, - _("`delete array' is a gawk extension")); + /* + * As of September 2012, POSIX has added support + * for `delete array'. See: + * http://austingroupbugs.net/view.php?id=544 + * + * Thanks to Nathan Weeks for the initiative. + * + * Thus we no longer warn or check do_posix. + * Also, since BWK awk supports it, we don't have to + * check do_traditional either. + */ $1->expr_count = 0; $$ = list_append(list_create($2), $1); } else { @@ -1011,7 +1008,7 @@ regular_print: } if (do_traditional) { error_ln($1->source_line, - _("`delete array' is a gawk extension")); + _("`delete(array)' is a non-portable tawk extension")); } $3->memory = variable($3->source_line, arr, Node_var_new); $3->opcode = Op_push_array; @@ -1862,7 +1859,7 @@ static const struct token tokentab[] = { {"match", Op_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_match, 0}, {"mktime", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_mktime, 0}, {"next", Op_K_next, LEX_NEXT, 0, 0, 0}, -{"nextfile", Op_K_nextfile, LEX_NEXTFILE, GAWKX, 0, 0}, +{"nextfile", Op_K_nextfile, LEX_NEXTFILE, 0, 0, 0}, {"or", Op_builtin, LEX_BUILTIN, GAWKX, do_or, MPF(or)}, {"patsplit", Op_builtin, LEX_BUILTIN, GAWKX|A(2)|A(3)|A(4), do_patsplit, 0}, {"print", Op_K_print, LEX_PRINT, 0, 0, 0}, diff --git a/doc/ChangeLog b/doc/ChangeLog index 7582e096..f84622d7 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,10 @@ +2012-09-23 Arnold D. Robbins <arnold@skeeve.com> + + * gawk.texi (Nextfile Statement): Document that it's now part of POSIX + and update the title. + (Delete): Document that `delete array' is now part of POSIX. + * awkcard.in: Adjust coloring for nextfile and delete array. + 2012-09-07 Arnold D. Robbins <arnold@skeeve.com> * texinfo.tex: Updated to version 2012-09-05.06. diff --git a/doc/awkcard.in b/doc/awkcard.in index 9f9f304a..372d5587 100644 --- a/doc/awkcard.in +++ b/doc/awkcard.in @@ -700,7 +700,7 @@ loop to iterate over all the elements of an array. .sp .5 Use the \*(FCdelete\fP statement to delete an element from an array. -\*(CLSpecifying just the array name without a subscript in +Specifying just the array name without a subscript in the \*(FCdelete\fP statement deletes the entire contents of an array. .sp .5 @@ -914,7 +914,7 @@ matches the closest \*(FCif\*(FR. .ti -.2i \*(FCnext\*(FR See \fHInput Control.\fP .ti -.2i -\*(CL\*(FCnextfile\*(FR See \fHInput Control.\fP\*(CD +\*(FCnextfile\*(FR See \fHInput Control.\fP .in -.2i .\" --- Start switch statement \*(CB\*(FCswitch (\*(FIexpression\*(FC) { @@ -1306,15 +1306,15 @@ program. Upon end of the input data, execute any \*(FCEND\fP rule(s). .br .ti -.2i -\*(CL\*(FCnextfile\fP +\*(FCnextfile\fP .br Stop processing the current input file. The next input record comes from the next input file. \*(FCFILENAME\fP \*(CBand -\*(FCARGIND\fP\*(CL are updated, \*(FCFNR\fP is reset to 1, +\*(FCARGIND\fP\*(CD are updated, \*(FCFNR\fP is reset to 1, and processing starts over with the first pattern in the AWK program. Upon end -of input data, execute any \*(FCEND\fP rule(s).\*(CD +of input data, execute any \*(FCEND\fP rule(s). .in -.2i .sp .5 .fi diff --git a/doc/gawk.info b/doc/gawk.info index 7f67d45c..2d75333d 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -9171,37 +9171,35 @@ starts processing it with the first rule in the program. File: gawk.info, Node: Nextfile Statement, Next: Exit Statement, Prev: Next Statement, Up: Statements -7.4.9 Using `gawk''s `nextfile' Statement ------------------------------------------ +7.4.9 The `nextfile' Statement +------------------------------ -`gawk' provides the `nextfile' statement, which is similar to the -`next' statement. (c.e.) However, instead of abandoning processing of -the current record, the `nextfile' statement instructs `gawk' to stop -processing the current data file. - - The `nextfile' statement is a `gawk' extension. In most other `awk' -implementations, or if `gawk' is in compatibility mode (*note -Options::), `nextfile' is not special. - - Upon execution of the `nextfile' statement, any `ENDFILE' rules are -executed except in the case as mentioned below, `FILENAME' is updated -to the name of the next data file listed on the command line, `FNR' is -reset to one, `ARGIND' is incremented, any `BEGINFILE' rules are -executed, and processing starts over with the first rule in the program. -(`ARGIND' hasn't been introduced yet. *Note Built-in Variables::.) If -the `nextfile' statement causes the end of the input to be reached, -then the code in any `END' rules is executed. An exception to this is -when the `nextfile' is invoked during execution of any statement in an -`END' rule; In this case, it causes the program to stop immediately. +The `nextfile' statement is similar to the `next' statement. However, +instead of abandoning processing of the current record, the `nextfile' +statement instructs `awk' to stop processing the current data file. + + Upon execution of the `nextfile' statement, `FILENAME' is updated to +the name of the next data file listed on the command line, `FNR' is +reset to one, and processing starts over with the first rule in the +program. If the `nextfile' statement causes the end of the input to be +reached, then the code in any `END' rules is executed. An exception to +this is when `nextfile' is invoked during execution of any statement in +an `END' rule; In this case, it causes the program to stop immediately. *Note BEGIN/END::. The `nextfile' statement is useful when there are many data files to process but it isn't necessary to process every record in every file. -Normally, in order to move on to the next data file, a program has to -continue scanning the unwanted records. The `nextfile' statement -accomplishes this much more efficiently. +Without `nextfile', in order to move on to the next data file, a program +would have to continue scanning the unwanted records. The `nextfile' +statement accomplishes this much more efficiently. + + In `gawk', execution of `nextfile' causes additional things to +happen: any `ENDFILE' rules are executed except in the case as +mentioned below, `ARGIND' is incremented, and any `BEGINFILE' rules are +executed (`ARGIND' hasn't been introduced yet. *Note Built-in +Variables::.) - In addition, `nextfile' is useful inside a `BEGINFILE' rule to skip + With `gawk', `nextfile' is useful inside a `BEGINFILE' rule to skip over a file that would otherwise cause `gawk' to exit with a fatal error. In this case, `ENDFILE' rules are not executed. *Note BEGINFILE/ENDFILE::. @@ -9212,6 +9210,11 @@ files, pipes, and coprocesses that are opened with redirections. It is not related to the main processing that `awk' does with the files listed in `ARGV'. + NOTE: For many years, `nextfile' was a `gawk' extension. As of + September, 2012, it was accepted for inclusion into the POSIX + standard. See the Austin Group website + (http://austingroupbugs.net/view.php?id=607). + The current version of the Brian Kernighan's `awk' (*note Other Versions::) also supports `nextfile'. However, it doesn't allow the `nextfile' statement inside function bodies (*note User-defined::). @@ -10355,18 +10358,22 @@ However, if `--lint' is provided on the command line (*note Options::), array is deleted. All the elements of an array may be deleted with a single statement -(c.e.) by leaving off the subscript in the `delete' statement, as -follows: +by leaving off the subscript in the `delete' statement, as follows: delete ARRAY - This ability is a `gawk' extension; it is not available in -compatibility mode (*note Options::). - Using this version of the `delete' statement is about three times more efficient than the equivalent loop that deletes each element one at a time. + NOTE: For many years, using `delete' without a subscript was a + `gawk' extension. As of September, 2012, it was accepted for + inclusion into the POSIX standard. See the Austin Group website + (http://austingroupbugs.net/view.php?id=544). This form of the + `delete' statement is also supported by Brian Kernighan's `awk' + and `mawk', as well as by a number of other implementations (*note + Other Versions::). + The following statement provides a portable but nonobvious way to clear out an array:(1) @@ -26255,7 +26262,7 @@ Index * Brennan, Michael <1>: Other Versions. (line 6) * Brennan, Michael <2>: Simple Sed. (line 25) * Brennan, Michael <3>: Two-way I/O. (line 6) -* Brennan, Michael: Delete. (line 52) +* Brennan, Michael: Delete. (line 56) * Brian Kernighan's awk, extensions <1>: Other Versions. (line 13) * Brian Kernighan's awk, extensions: BTL. (line 6) * Broder, Alan J.: Contributors. (line 88) @@ -27031,7 +27038,7 @@ Index * functions, user-defined, counts: Profiling. (line 129) * functions, user-defined, library of: Library Functions. (line 6) * functions, user-defined, next/nextfile statements and <1>: Nextfile Statement. - (line 44) + (line 47) * functions, user-defined, next/nextfile statements and: Next Statement. (line 45) * G-d: Acknowledgments. (line 83) @@ -27515,7 +27522,7 @@ Index * nextfile statement, BEGINFILE/ENDFILE patterns and: BEGINFILE/ENDFILE. (line 26) * nextfile statement, user-defined functions and: Nextfile Statement. - (line 44) + (line 47) * nexti debugger command: Debugger Execution Control. (line 49) * NF variable <1>: Auto-set. (line 108) @@ -27694,7 +27701,7 @@ Index * portability, close() function and: Close Files And Pipes. (line 81) * portability, data files as single record: Records. (line 180) -* portability, deleting array elements: Delete. (line 52) +* portability, deleting array elements: Delete. (line 56) * portability, example programs: Library Functions. (line 31) * portability, fflush() function and: I/O Functions. (line 29) * portability, functions, defining: Definition Syntax. (line 99) @@ -28103,7 +28110,7 @@ Index * Spencer, Henry: Glossary. (line 12) * split utility: Split Program. (line 6) * split() function: String Functions. (line 315) -* split() function, array elements, deleting: Delete. (line 57) +* split() function, array elements, deleting: Delete. (line 61) * split.awk program: Split Program. (line 30) * sprintf() function <1>: String Functions. (line 380) * sprintf() function: OFMT. (line 15) @@ -28601,269 +28608,269 @@ Node: Break Statement382649 Node: Continue Statement384639 Node: Next Statement386432 Node: Nextfile Statement388822 -Node: Exit Statement391367 -Node: Built-in Variables393783 -Node: User-modified394878 -Ref: User-modified-Footnote-1403233 -Node: Auto-set403295 -Ref: Auto-set-Footnote-1413203 -Node: ARGC and ARGV413408 -Node: Arrays417259 -Node: Array Basics418764 -Node: Array Intro419590 -Node: Reference to Elements423908 -Node: Assigning Elements426178 -Node: Array Example426669 -Node: Scanning an Array428401 -Node: Controlling Scanning430715 -Ref: Controlling Scanning-Footnote-1435648 -Node: Delete435964 -Ref: Delete-Footnote-1438399 -Node: Numeric Array Subscripts438456 -Node: Uninitialized Subscripts440639 -Node: Multi-dimensional442267 -Node: Multi-scanning445361 -Node: Arrays of Arrays446952 -Node: Functions451597 -Node: Built-in452419 -Node: Calling Built-in453497 -Node: Numeric Functions455485 -Ref: Numeric Functions-Footnote-1459317 -Ref: Numeric Functions-Footnote-2459674 -Ref: Numeric Functions-Footnote-3459722 -Node: String Functions459991 -Ref: String Functions-Footnote-1483488 -Ref: String Functions-Footnote-2483617 -Ref: String Functions-Footnote-3483865 -Node: Gory Details483952 -Ref: table-sub-escapes485631 -Ref: table-sub-posix-92486985 -Ref: table-sub-proposed488328 -Ref: table-posix-sub489678 -Ref: table-gensub-escapes491224 -Ref: Gory Details-Footnote-1492431 -Ref: Gory Details-Footnote-2492482 -Node: I/O Functions492633 -Ref: I/O Functions-Footnote-1499288 -Node: Time Functions499435 -Ref: Time Functions-Footnote-1510327 -Ref: Time Functions-Footnote-2510395 -Ref: Time Functions-Footnote-3510553 -Ref: Time Functions-Footnote-4510664 -Ref: Time Functions-Footnote-5510776 -Ref: Time Functions-Footnote-6511003 -Node: Bitwise Functions511269 -Ref: table-bitwise-ops511827 -Ref: Bitwise Functions-Footnote-1516048 -Node: Type Functions516232 -Node: I18N Functions516702 -Node: User-defined518329 -Node: Definition Syntax519133 -Ref: Definition Syntax-Footnote-1524043 -Node: Function Example524112 -Node: Function Caveats526706 -Node: Calling A Function527127 -Node: Variable Scope528242 -Node: Pass By Value/Reference530217 -Node: Return Statement533657 -Node: Dynamic Typing536638 -Node: Indirect Calls537373 -Node: Internationalization547058 -Node: I18N and L10N548484 -Node: Explaining gettext549170 -Ref: Explaining gettext-Footnote-1554236 -Ref: Explaining gettext-Footnote-2554420 -Node: Programmer i18n554585 -Node: Translator i18n558785 -Node: String Extraction559578 -Ref: String Extraction-Footnote-1560539 -Node: Printf Ordering560625 -Ref: Printf Ordering-Footnote-1563409 -Node: I18N Portability563473 -Ref: I18N Portability-Footnote-1565922 -Node: I18N Example565985 -Ref: I18N Example-Footnote-1568620 -Node: Gawk I18N568692 -Node: Advanced Features569309 -Node: Nondecimal Data570822 -Node: Array Sorting572405 -Node: Controlling Array Traversal573102 -Node: Array Sorting Functions581340 -Ref: Array Sorting Functions-Footnote-1585014 -Ref: Array Sorting Functions-Footnote-2585107 -Node: Two-way I/O585301 -Ref: Two-way I/O-Footnote-1590733 -Node: TCP/IP Networking590803 -Node: Profiling593647 -Node: Library Functions601101 -Ref: Library Functions-Footnote-1604108 -Node: Library Names604279 -Ref: Library Names-Footnote-1607750 -Ref: Library Names-Footnote-2607970 -Node: General Functions608056 -Node: Strtonum Function609009 -Node: Assert Function611939 -Node: Round Function615265 -Node: Cliff Random Function616808 -Node: Ordinal Functions617824 -Ref: Ordinal Functions-Footnote-1620894 -Ref: Ordinal Functions-Footnote-2621146 -Node: Join Function621355 -Ref: Join Function-Footnote-1623126 -Node: Getlocaltime Function623326 -Node: Data File Management627041 -Node: Filetrans Function627673 -Node: Rewind Function631812 -Node: File Checking633199 -Node: Empty Files634293 -Node: Ignoring Assigns636523 -Node: Getopt Function638076 -Ref: Getopt Function-Footnote-1649380 -Node: Passwd Functions649583 -Ref: Passwd Functions-Footnote-1658558 -Node: Group Functions658646 -Node: Walking Arrays666730 -Node: Sample Programs668299 -Node: Running Examples668964 -Node: Clones669692 -Node: Cut Program670916 -Node: Egrep Program680761 -Ref: Egrep Program-Footnote-1688534 -Node: Id Program688644 -Node: Split Program692260 -Ref: Split Program-Footnote-1695779 -Node: Tee Program695907 -Node: Uniq Program698710 -Node: Wc Program706139 -Ref: Wc Program-Footnote-1710405 -Ref: Wc Program-Footnote-2710605 -Node: Miscellaneous Programs710697 -Node: Dupword Program711885 -Node: Alarm Program713916 -Node: Translate Program718665 -Ref: Translate Program-Footnote-1723052 -Ref: Translate Program-Footnote-2723280 -Node: Labels Program723414 -Ref: Labels Program-Footnote-1726785 -Node: Word Sorting726869 -Node: History Sorting730753 -Node: Extract Program732592 -Ref: Extract Program-Footnote-1740075 -Node: Simple Sed740203 -Node: Igawk Program743265 -Ref: Igawk Program-Footnote-1758422 -Ref: Igawk Program-Footnote-2758623 -Node: Anagram Program758761 -Node: Signature Program761829 -Node: Debugger762929 -Node: Debugging763895 -Node: Debugging Concepts764328 -Node: Debugging Terms766184 -Node: Awk Debugging768781 -Node: Sample Debugging Session769673 -Node: Debugger Invocation770193 -Node: Finding The Bug771522 -Node: List of Debugger Commands778010 -Node: Breakpoint Control779344 -Node: Debugger Execution Control783008 -Node: Viewing And Changing Data786368 -Node: Execution Stack789724 -Node: Debugger Info791191 -Node: Miscellaneous Debugger Commands795172 -Node: Readline Support800617 -Node: Limitations801448 -Node: Arbitrary Precision Arithmetic803700 -Ref: Arbitrary Precision Arithmetic-Footnote-1805342 -Node: General Arithmetic805490 -Node: Floating Point Issues807210 -Node: String Conversion Precision808091 -Ref: String Conversion Precision-Footnote-1809797 -Node: Unexpected Results809906 -Node: POSIX Floating Point Problems812059 -Ref: POSIX Floating Point Problems-Footnote-1815884 -Node: Integer Programming815922 -Node: Floating-point Programming817675 -Ref: Floating-point Programming-Footnote-1823984 -Node: Floating-point Representation824248 -Node: Floating-point Context825413 -Ref: table-ieee-formats826255 -Node: Rounding Mode827639 -Ref: table-rounding-modes828118 -Ref: Rounding Mode-Footnote-1831122 -Node: Gawk and MPFR831303 -Node: Arbitrary Precision Floats832545 -Ref: Arbitrary Precision Floats-Footnote-1834974 -Node: Setting Precision835285 -Node: Setting Rounding Mode838018 -Ref: table-gawk-rounding-modes838422 -Node: Floating-point Constants839602 -Node: Changing Precision841026 -Ref: Changing Precision-Footnote-1842426 -Node: Exact Arithmetic842600 -Node: Arbitrary Precision Integers845708 -Ref: Arbitrary Precision Integers-Footnote-1848708 -Node: Dynamic Extensions848855 -Node: Plugin License849773 -Node: Sample Library850387 -Node: Internal File Description851071 -Node: Internal File Ops854784 -Ref: Internal File Ops-Footnote-1859347 -Node: Using Internal File Ops859487 -Node: Language History861863 -Node: V7/SVR3.1863385 -Node: SVR4865706 -Node: POSIX867148 -Node: BTL868156 -Node: POSIX/GNU868890 -Node: Common Extensions874425 -Node: Ranges and Locales875532 -Ref: Ranges and Locales-Footnote-1880150 -Ref: Ranges and Locales-Footnote-2880177 -Ref: Ranges and Locales-Footnote-3880437 -Node: Contributors880658 -Node: Installation884954 -Node: Gawk Distribution885848 -Node: Getting886332 -Node: Extracting887158 -Node: Distribution contents888850 -Node: Unix Installation894072 -Node: Quick Installation894689 -Node: Additional Configuration Options896651 -Node: Configuration Philosophy898128 -Node: Non-Unix Installation900470 -Node: PC Installation900928 -Node: PC Binary Installation902227 -Node: PC Compiling904075 -Node: PC Testing907019 -Node: PC Using908195 -Node: Cygwin912380 -Node: MSYS913380 -Node: VMS Installation913894 -Node: VMS Compilation914497 -Ref: VMS Compilation-Footnote-1915504 -Node: VMS Installation Details915562 -Node: VMS Running917197 -Node: VMS Old Gawk918804 -Node: Bugs919278 -Node: Other Versions923130 -Node: Notes928445 -Node: Compatibility Mode929032 -Node: Additions929815 -Node: Accessing The Source930742 -Node: Adding Code932168 -Node: New Ports938210 -Node: Derived Files942345 -Ref: Derived Files-Footnote-1947650 -Ref: Derived Files-Footnote-2947684 -Ref: Derived Files-Footnote-3948284 -Node: Future Extensions948382 -Node: Basic Concepts949869 -Node: Basic High Level950550 -Ref: Basic High Level-Footnote-1954585 -Node: Basic Data Typing954770 -Node: Glossary958125 -Node: Copying983101 -Node: GNU Free Documentation License1020658 -Node: Index1045795 +Node: Exit Statement391463 +Node: Built-in Variables393879 +Node: User-modified394974 +Ref: User-modified-Footnote-1403329 +Node: Auto-set403391 +Ref: Auto-set-Footnote-1413299 +Node: ARGC and ARGV413504 +Node: Arrays417355 +Node: Array Basics418860 +Node: Array Intro419686 +Node: Reference to Elements424004 +Node: Assigning Elements426274 +Node: Array Example426765 +Node: Scanning an Array428497 +Node: Controlling Scanning430811 +Ref: Controlling Scanning-Footnote-1435744 +Node: Delete436060 +Ref: Delete-Footnote-1438825 +Node: Numeric Array Subscripts438882 +Node: Uninitialized Subscripts441065 +Node: Multi-dimensional442693 +Node: Multi-scanning445787 +Node: Arrays of Arrays447378 +Node: Functions452023 +Node: Built-in452845 +Node: Calling Built-in453923 +Node: Numeric Functions455911 +Ref: Numeric Functions-Footnote-1459743 +Ref: Numeric Functions-Footnote-2460100 +Ref: Numeric Functions-Footnote-3460148 +Node: String Functions460417 +Ref: String Functions-Footnote-1483914 +Ref: String Functions-Footnote-2484043 +Ref: String Functions-Footnote-3484291 +Node: Gory Details484378 +Ref: table-sub-escapes486057 +Ref: table-sub-posix-92487411 +Ref: table-sub-proposed488754 +Ref: table-posix-sub490104 +Ref: table-gensub-escapes491650 +Ref: Gory Details-Footnote-1492857 +Ref: Gory Details-Footnote-2492908 +Node: I/O Functions493059 +Ref: I/O Functions-Footnote-1499714 +Node: Time Functions499861 +Ref: Time Functions-Footnote-1510753 +Ref: Time Functions-Footnote-2510821 +Ref: Time Functions-Footnote-3510979 +Ref: Time Functions-Footnote-4511090 +Ref: Time Functions-Footnote-5511202 +Ref: Time Functions-Footnote-6511429 +Node: Bitwise Functions511695 +Ref: table-bitwise-ops512253 +Ref: Bitwise Functions-Footnote-1516474 +Node: Type Functions516658 +Node: I18N Functions517128 +Node: User-defined518755 +Node: Definition Syntax519559 +Ref: Definition Syntax-Footnote-1524469 +Node: Function Example524538 +Node: Function Caveats527132 +Node: Calling A Function527553 +Node: Variable Scope528668 +Node: Pass By Value/Reference530643 +Node: Return Statement534083 +Node: Dynamic Typing537064 +Node: Indirect Calls537799 +Node: Internationalization547484 +Node: I18N and L10N548910 +Node: Explaining gettext549596 +Ref: Explaining gettext-Footnote-1554662 +Ref: Explaining gettext-Footnote-2554846 +Node: Programmer i18n555011 +Node: Translator i18n559211 +Node: String Extraction560004 +Ref: String Extraction-Footnote-1560965 +Node: Printf Ordering561051 +Ref: Printf Ordering-Footnote-1563835 +Node: I18N Portability563899 +Ref: I18N Portability-Footnote-1566348 +Node: I18N Example566411 +Ref: I18N Example-Footnote-1569046 +Node: Gawk I18N569118 +Node: Advanced Features569735 +Node: Nondecimal Data571248 +Node: Array Sorting572831 +Node: Controlling Array Traversal573528 +Node: Array Sorting Functions581766 +Ref: Array Sorting Functions-Footnote-1585440 +Ref: Array Sorting Functions-Footnote-2585533 +Node: Two-way I/O585727 +Ref: Two-way I/O-Footnote-1591159 +Node: TCP/IP Networking591229 +Node: Profiling594073 +Node: Library Functions601527 +Ref: Library Functions-Footnote-1604534 +Node: Library Names604705 +Ref: Library Names-Footnote-1608176 +Ref: Library Names-Footnote-2608396 +Node: General Functions608482 +Node: Strtonum Function609435 +Node: Assert Function612365 +Node: Round Function615691 +Node: Cliff Random Function617234 +Node: Ordinal Functions618250 +Ref: Ordinal Functions-Footnote-1621320 +Ref: Ordinal Functions-Footnote-2621572 +Node: Join Function621781 +Ref: Join Function-Footnote-1623552 +Node: Getlocaltime Function623752 +Node: Data File Management627467 +Node: Filetrans Function628099 +Node: Rewind Function632238 +Node: File Checking633625 +Node: Empty Files634719 +Node: Ignoring Assigns636949 +Node: Getopt Function638502 +Ref: Getopt Function-Footnote-1649806 +Node: Passwd Functions650009 +Ref: Passwd Functions-Footnote-1658984 +Node: Group Functions659072 +Node: Walking Arrays667156 +Node: Sample Programs668725 +Node: Running Examples669390 +Node: Clones670118 +Node: Cut Program671342 +Node: Egrep Program681187 +Ref: Egrep Program-Footnote-1688960 +Node: Id Program689070 +Node: Split Program692686 +Ref: Split Program-Footnote-1696205 +Node: Tee Program696333 +Node: Uniq Program699136 +Node: Wc Program706565 +Ref: Wc Program-Footnote-1710831 +Ref: Wc Program-Footnote-2711031 +Node: Miscellaneous Programs711123 +Node: Dupword Program712311 +Node: Alarm Program714342 +Node: Translate Program719091 +Ref: Translate Program-Footnote-1723478 +Ref: Translate Program-Footnote-2723706 +Node: Labels Program723840 +Ref: Labels Program-Footnote-1727211 +Node: Word Sorting727295 +Node: History Sorting731179 +Node: Extract Program733018 +Ref: Extract Program-Footnote-1740501 +Node: Simple Sed740629 +Node: Igawk Program743691 +Ref: Igawk Program-Footnote-1758848 +Ref: Igawk Program-Footnote-2759049 +Node: Anagram Program759187 +Node: Signature Program762255 +Node: Debugger763355 +Node: Debugging764321 +Node: Debugging Concepts764754 +Node: Debugging Terms766610 +Node: Awk Debugging769207 +Node: Sample Debugging Session770099 +Node: Debugger Invocation770619 +Node: Finding The Bug771948 +Node: List of Debugger Commands778436 +Node: Breakpoint Control779770 +Node: Debugger Execution Control783434 +Node: Viewing And Changing Data786794 +Node: Execution Stack790150 +Node: Debugger Info791617 +Node: Miscellaneous Debugger Commands795598 +Node: Readline Support801043 +Node: Limitations801874 +Node: Arbitrary Precision Arithmetic804126 +Ref: Arbitrary Precision Arithmetic-Footnote-1805768 +Node: General Arithmetic805916 +Node: Floating Point Issues807636 +Node: String Conversion Precision808517 +Ref: String Conversion Precision-Footnote-1810223 +Node: Unexpected Results810332 +Node: POSIX Floating Point Problems812485 +Ref: POSIX Floating Point Problems-Footnote-1816310 +Node: Integer Programming816348 +Node: Floating-point Programming818101 +Ref: Floating-point Programming-Footnote-1824410 +Node: Floating-point Representation824674 +Node: Floating-point Context825839 +Ref: table-ieee-formats826681 +Node: Rounding Mode828065 +Ref: table-rounding-modes828544 +Ref: Rounding Mode-Footnote-1831548 +Node: Gawk and MPFR831729 +Node: Arbitrary Precision Floats832971 +Ref: Arbitrary Precision Floats-Footnote-1835400 +Node: Setting Precision835711 +Node: Setting Rounding Mode838444 +Ref: table-gawk-rounding-modes838848 +Node: Floating-point Constants840028 +Node: Changing Precision841452 +Ref: Changing Precision-Footnote-1842852 +Node: Exact Arithmetic843026 +Node: Arbitrary Precision Integers846134 +Ref: Arbitrary Precision Integers-Footnote-1849134 +Node: Dynamic Extensions849281 +Node: Plugin License850199 +Node: Sample Library850813 +Node: Internal File Description851497 +Node: Internal File Ops855210 +Ref: Internal File Ops-Footnote-1859773 +Node: Using Internal File Ops859913 +Node: Language History862289 +Node: V7/SVR3.1863811 +Node: SVR4866132 +Node: POSIX867574 +Node: BTL868582 +Node: POSIX/GNU869316 +Node: Common Extensions874851 +Node: Ranges and Locales875958 +Ref: Ranges and Locales-Footnote-1880576 +Ref: Ranges and Locales-Footnote-2880603 +Ref: Ranges and Locales-Footnote-3880863 +Node: Contributors881084 +Node: Installation885380 +Node: Gawk Distribution886274 +Node: Getting886758 +Node: Extracting887584 +Node: Distribution contents889276 +Node: Unix Installation894498 +Node: Quick Installation895115 +Node: Additional Configuration Options897077 +Node: Configuration Philosophy898554 +Node: Non-Unix Installation900896 +Node: PC Installation901354 +Node: PC Binary Installation902653 +Node: PC Compiling904501 +Node: PC Testing907445 +Node: PC Using908621 +Node: Cygwin912806 +Node: MSYS913806 +Node: VMS Installation914320 +Node: VMS Compilation914923 +Ref: VMS Compilation-Footnote-1915930 +Node: VMS Installation Details915988 +Node: VMS Running917623 +Node: VMS Old Gawk919230 +Node: Bugs919704 +Node: Other Versions923556 +Node: Notes928871 +Node: Compatibility Mode929458 +Node: Additions930241 +Node: Accessing The Source931168 +Node: Adding Code932594 +Node: New Ports938636 +Node: Derived Files942771 +Ref: Derived Files-Footnote-1948076 +Ref: Derived Files-Footnote-2948110 +Ref: Derived Files-Footnote-3948710 +Node: Future Extensions948808 +Node: Basic Concepts950295 +Node: Basic High Level950976 +Ref: Basic High Level-Footnote-1955011 +Node: Basic Data Typing955196 +Node: Glossary958551 +Node: Copying983527 +Node: GNU Free Documentation License1021084 +Node: Index1046221 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 9519060e..d9c20831 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -12409,44 +12409,46 @@ function body reads the next record and starts processing it with the first rule in the program. @node Nextfile Statement -@subsection Using @command{gawk}'s @code{nextfile} Statement +@subsection The @code{nextfile} Statement @cindex @code{nextfile} statement @cindex differences in @command{awk} and @command{gawk}, @code{next}/@code{nextfile} statements @cindex common extensions, @code{nextfile} statement @cindex extensions, common@comma{} @code{nextfile} statement -@command{gawk} provides the @code{nextfile} statement, -which is similar to the @code{next} statement. @value{COMMONEXT} +The @code{nextfile} statement +is similar to the @code{next} statement. However, instead of abandoning processing of the current record, the -@code{nextfile} statement instructs @command{gawk} to stop processing the +@code{nextfile} statement instructs @command{awk} to stop processing the current @value{DF}. -The @code{nextfile} statement is a @command{gawk} extension. -In most other @command{awk} implementations, -or if @command{gawk} is in compatibility mode -(@pxref{Options}), -@code{nextfile} is not special. - Upon execution of the @code{nextfile} statement, -any @code{ENDFILE} rules are executed except in the case as -mentioned below, @code{FILENAME} is +@code{FILENAME} is updated to the name of the next @value{DF} listed on the command line, -@code{FNR} is reset to one, @code{ARGIND} is incremented, -any @code{BEGINFILE} rules are executed, and processing +@code{FNR} is reset to one, +and processing starts over with the first rule in the program. -(@code{ARGIND} hasn't been introduced yet. @xref{Built-in Variables}.) If the @code{nextfile} statement causes the end of the input to be reached, then the code in any @code{END} rules is executed. An exception to this is -when the @code{nextfile} is invoked during execution of any statement in an +when @code{nextfile} is invoked during execution of any statement in an @code{END} rule; In this case, it causes the program to stop immediately. @xref{BEGIN/END}. The @code{nextfile} statement is useful when there are many @value{DF}s to process but it isn't necessary to process every record in every file. -Normally, in order to move on to the next @value{DF}, a program -has to continue scanning the unwanted records. The @code{nextfile} +Without @code{nextfile}, +in order to move on to the next @value{DF}, a program +would have to continue scanning the unwanted records. The @code{nextfile} statement accomplishes this much more efficiently. -In addition, @code{nextfile} is useful inside a @code{BEGINFILE} +In @command{gawk}, execution of @code{nextfile} causes additional things +to happen: +any @code{ENDFILE} rules are executed except in the case as +mentioned below, +@code{ARGIND} is incremented, +and +any @code{BEGINFILE} rules are executed +(@code{ARGIND} hasn't been introduced yet. @xref{Built-in Variables}.) + +With @command{gawk}, @code{nextfile} is useful inside a @code{BEGINFILE} rule to skip over a file that would otherwise cause @command{gawk} to exit with a fatal error. In this case, @code{ENDFILE} rules are not executed. @xref{BEGINFILE/ENDFILE}. @@ -12457,6 +12459,13 @@ reserved for closing files, pipes, and coprocesses that are opened with redirections. It is not related to the main processing that @command{awk} does with the files listed in @code{ARGV}. +@quotation NOTE +For many years, @code{nextfile} was a +@command{gawk} extension. As of September, 2012, it was accepted for +inclusion into the POSIX standard. +See @uref{http://austingroupbugs.net/view.php?id=607, the Austin Group website}. +@end quotation + @cindex functions, user-defined, @code{next}/@code{nextfile} statements and @cindex @code{nextfile} statement, user-defined functions and The current version of the Brian Kernighan's @command{awk} (@pxref{Other @@ -13951,21 +13960,28 @@ is not in the array is deleted. @cindex deleting entire arrays @cindex differences in @command{awk} and @command{gawk}, array elements, deleting All the elements of an array may be deleted with a single statement -@value{COMMONEXT} by leaving off the subscript in the @code{delete} statement, as follows: + @example delete @var{array} @end example -This ability is a @command{gawk} extension; it is not available in -compatibility mode (@pxref{Options}). - Using this version of the @code{delete} statement is about three times more efficient than the equivalent loop that deletes each element one at a time. +@quotation NOTE +For many years, +using @code{delete} without a subscript was a @command{gawk} extension. +As of September, 2012, it was accepted for +inclusion into the POSIX standard. See @uref{http://austingroupbugs.net/view.php?id=544, +the Austin Group website}. This form of the @code{delete} statement is also supported +by Brian Kernighan's @command{awk} and @command{mawk}, as well as +by a number of other implementations (@pxref{Other Versions}). +@end quotation + @cindex portability, deleting array elements @cindex Brennan, Michael The following statement provides a portable but nonobvious way to clear diff --git a/test/ChangeLog b/test/ChangeLog index 643fe8d0..b8e55945 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2012-09-23 Arnold D. Robbins <arnold@skeeve.com> + + * lintwarn.ok: Updated. + 2012-09-14 Arnold D. Robbins <arnold@skeeve.com> * testext.ok: Updated. Twice. diff --git a/test/lintwarn.ok b/test/lintwarn.ok index 169b0020..312d40d4 100644 --- a/test/lintwarn.ok +++ b/test/lintwarn.ok @@ -3,9 +3,7 @@ gawk: lintwarn.awk:3: error: `getline var' invalid inside `BEGINFILE' rule gawk: lintwarn.awk:4: error: `getline' invalid inside `BEGINFILE' rule gawk: lintwarn.awk:8: warning: statement may have no effect gawk: lintwarn.awk:9: warning: plain `print' in BEGIN or END rule should probably be `print ""' -gawk: lintwarn.awk:10: warning: `nextfile' is a gawk extension gawk: lintwarn.awk:10: error: `nextfile' used in BEGIN action -gawk: lintwarn.awk:11: warning: `delete array' is a gawk extension gawk: lintwarn.awk:12: warning: `delete(array)' is a non-portable tawk extension gawk: lintwarn.awk:13: warning: regular expression on right of assignment gawk: lintwarn.awk:14: warning: regular expression on right of comparison |