diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | awkgram.c | 299 | ||||
-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 | 551 | ||||
-rw-r--r-- | doc/gawk.texi | 62 | ||||
-rw-r--r-- | test/ChangeLog | 4 | ||||
-rw-r--r-- | test/lintwarn.ok | 2 |
9 files changed, 505 insertions, 469 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-08-17 Arnold D. Robbins <arnold@skeeve.com> * Update infrastructure to automake 1.12.3, bison 2.6.3. @@ -755,20 +755,20 @@ static const yytype_uint16 yyrline[] = 346, 355, 365, 367, 369, 380, 385, 386, 391, 390, 420, 419, 452, 454, 459, 460, 473, 478, 479, 483, 485, 487, 494, 584, 626, 668, 781, 788, 795, 805, - 814, 823, 832, 847, 863, 862, 874, 886, 886, 982, - 982, 1007, 1030, 1036, 1037, 1043, 1044, 1051, 1056, 1068, - 1082, 1084, 1090, 1095, 1097, 1105, 1107, 1116, 1117, 1125, - 1130, 1130, 1141, 1145, 1153, 1154, 1157, 1159, 1164, 1165, - 1172, 1174, 1178, 1184, 1191, 1193, 1195, 1202, 1203, 1209, - 1210, 1215, 1217, 1222, 1224, 1226, 1228, 1234, 1241, 1243, - 1245, 1261, 1271, 1278, 1280, 1285, 1287, 1289, 1297, 1299, - 1304, 1306, 1311, 1313, 1315, 1368, 1370, 1372, 1374, 1376, - 1378, 1380, 1382, 1405, 1410, 1415, 1440, 1446, 1448, 1450, - 1452, 1454, 1456, 1461, 1465, 1496, 1498, 1504, 1510, 1523, - 1524, 1525, 1530, 1535, 1539, 1543, 1555, 1568, 1573, 1609, - 1627, 1628, 1634, 1635, 1640, 1642, 1649, 1666, 1683, 1685, - 1692, 1697, 1705, 1719, 1731, 1740, 1744, 1748, 1752, 1756, - 1760, 1763, 1765, 1769, 1773, 1777 + 814, 823, 832, 843, 859, 858, 870, 882, 882, 978, + 978, 1004, 1027, 1033, 1034, 1040, 1041, 1048, 1053, 1065, + 1079, 1081, 1087, 1092, 1094, 1102, 1104, 1113, 1114, 1122, + 1127, 1127, 1138, 1142, 1150, 1151, 1154, 1156, 1161, 1162, + 1169, 1171, 1175, 1181, 1188, 1190, 1192, 1199, 1200, 1206, + 1207, 1212, 1214, 1219, 1221, 1223, 1225, 1231, 1238, 1240, + 1242, 1258, 1268, 1275, 1277, 1282, 1284, 1286, 1294, 1296, + 1301, 1303, 1308, 1310, 1312, 1365, 1367, 1369, 1371, 1373, + 1375, 1377, 1379, 1402, 1407, 1412, 1437, 1443, 1445, 1447, + 1449, 1451, 1453, 1458, 1462, 1493, 1495, 1501, 1507, 1520, + 1521, 1522, 1527, 1532, 1536, 1540, 1552, 1565, 1570, 1606, + 1624, 1625, 1631, 1632, 1637, 1639, 1646, 1663, 1680, 1682, + 1689, 1694, 1702, 1716, 1728, 1737, 1741, 1745, 1749, 1753, + 1757, 1760, 1762, 1766, 1770, 1774 }; #endif @@ -2812,10 +2812,6 @@ regular_loop: /* Line 1787 of yacc.c */ #line 833 "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, @@ -2829,7 +2825,7 @@ regular_loop: case 53: /* Line 1787 of yacc.c */ -#line 848 "awkgram.y" +#line 844 "awkgram.y" { /* Initialize the two possible jump targets, the actual target * is resolved at run-time. @@ -2848,7 +2844,7 @@ regular_loop: case 54: /* Line 1787 of yacc.c */ -#line 863 "awkgram.y" +#line 859 "awkgram.y" { if (! can_return) yyerror(_("`return' used outside function context")); @@ -2857,7 +2853,7 @@ regular_loop: case 55: /* Line 1787 of yacc.c */ -#line 866 "awkgram.y" +#line 862 "awkgram.y" { if ((yyvsp[(3) - (4)]) == NULL) { (yyval) = list_create((yyvsp[(1) - (4)])); @@ -2870,13 +2866,13 @@ regular_loop: case 57: /* Line 1787 of yacc.c */ -#line 886 "awkgram.y" +#line 882 "awkgram.y" { in_print = TRUE; in_parens = 0; } break; case 58: /* Line 1787 of yacc.c */ -#line 887 "awkgram.y" +#line 883 "awkgram.y" { /* * Optimization: plain `print' has no expression list, so $3 is null. @@ -2975,13 +2971,13 @@ regular_loop: case 59: /* Line 1787 of yacc.c */ -#line 982 "awkgram.y" +#line 978 "awkgram.y" { sub_counter = 0; } break; case 60: /* Line 1787 of yacc.c */ -#line 983 "awkgram.y" +#line 979 "awkgram.y" { char *arr = (yyvsp[(2) - (4)])->lextok; @@ -2989,16 +2985,17 @@ regular_loop: (yyvsp[(2) - (4)])->memory = variable(arr, Node_var_new); if ((yyvsp[(4) - (4)]) == NULL) { - static short 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 { @@ -3010,7 +3007,7 @@ regular_loop: case 61: /* Line 1787 of yacc.c */ -#line 1012 "awkgram.y" +#line 1009 "awkgram.y" { static short warned = FALSE; char *arr = (yyvsp[(3) - (4)])->lextok; @@ -3022,7 +3019,7 @@ regular_loop: } 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(arr, Node_var_new); (yyvsp[(3) - (4)])->opcode = Op_push_array; @@ -3033,31 +3030,31 @@ regular_loop: case 62: /* Line 1787 of yacc.c */ -#line 1031 "awkgram.y" +#line 1028 "awkgram.y" { (yyval) = optimize_assignment((yyvsp[(1) - (1)])); } break; case 63: /* Line 1787 of yacc.c */ -#line 1036 "awkgram.y" +#line 1033 "awkgram.y" { (yyval) = NULL; } break; case 64: /* Line 1787 of yacc.c */ -#line 1038 "awkgram.y" +#line 1035 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 65: /* Line 1787 of yacc.c */ -#line 1043 "awkgram.y" +#line 1040 "awkgram.y" { (yyval) = NULL; } break; case 66: /* Line 1787 of yacc.c */ -#line 1045 "awkgram.y" +#line 1042 "awkgram.y" { if ((yyvsp[(1) - (2)]) == NULL) (yyval) = list_create((yyvsp[(2) - (2)])); @@ -3068,13 +3065,13 @@ regular_loop: case 67: /* Line 1787 of yacc.c */ -#line 1052 "awkgram.y" +#line 1049 "awkgram.y" { (yyval) = NULL; } break; case 68: /* Line 1787 of yacc.c */ -#line 1057 "awkgram.y" +#line 1054 "awkgram.y" { INSTRUCTION *casestmt = (yyvsp[(5) - (5)]); if ((yyvsp[(5) - (5)]) == NULL) @@ -3090,7 +3087,7 @@ regular_loop: case 69: /* Line 1787 of yacc.c */ -#line 1069 "awkgram.y" +#line 1066 "awkgram.y" { INSTRUCTION *casestmt = (yyvsp[(4) - (4)]); if ((yyvsp[(4) - (4)]) == NULL) @@ -3105,13 +3102,13 @@ regular_loop: case 70: /* Line 1787 of yacc.c */ -#line 1083 "awkgram.y" +#line 1080 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 71: /* Line 1787 of yacc.c */ -#line 1085 "awkgram.y" +#line 1082 "awkgram.y" { (yyvsp[(2) - (2)])->memory->numbr = -(force_number((yyvsp[(2) - (2)])->memory)); bcfree((yyvsp[(1) - (2)])); @@ -3121,7 +3118,7 @@ regular_loop: case 72: /* Line 1787 of yacc.c */ -#line 1091 "awkgram.y" +#line 1088 "awkgram.y" { bcfree((yyvsp[(1) - (2)])); (yyval) = (yyvsp[(2) - (2)]); @@ -3130,13 +3127,13 @@ regular_loop: case 73: /* Line 1787 of yacc.c */ -#line 1096 "awkgram.y" +#line 1093 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 74: /* Line 1787 of yacc.c */ -#line 1098 "awkgram.y" +#line 1095 "awkgram.y" { (yyvsp[(1) - (1)])->opcode = Op_push_re; (yyval) = (yyvsp[(1) - (1)]); @@ -3145,19 +3142,19 @@ regular_loop: case 75: /* Line 1787 of yacc.c */ -#line 1106 "awkgram.y" +#line 1103 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 76: /* Line 1787 of yacc.c */ -#line 1108 "awkgram.y" +#line 1105 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 78: /* Line 1787 of yacc.c */ -#line 1118 "awkgram.y" +#line 1115 "awkgram.y" { (yyval) = (yyvsp[(2) - (3)]); } @@ -3165,7 +3162,7 @@ regular_loop: case 79: /* Line 1787 of yacc.c */ -#line 1125 "awkgram.y" +#line 1122 "awkgram.y" { in_print = FALSE; in_parens = 0; @@ -3175,13 +3172,13 @@ regular_loop: case 80: /* Line 1787 of yacc.c */ -#line 1130 "awkgram.y" +#line 1127 "awkgram.y" { in_print = FALSE; in_parens = 0; } break; case 81: /* Line 1787 of yacc.c */ -#line 1131 "awkgram.y" +#line 1128 "awkgram.y" { if ((yyvsp[(1) - (3)])->redir_type == redirect_twoway && (yyvsp[(3) - (3)])->lasti->opcode == Op_K_getline_redir @@ -3193,7 +3190,7 @@ regular_loop: case 82: /* Line 1787 of yacc.c */ -#line 1142 "awkgram.y" +#line 1139 "awkgram.y" { (yyval) = mk_condition((yyvsp[(3) - (6)]), (yyvsp[(1) - (6)]), (yyvsp[(6) - (6)]), NULL, NULL); } @@ -3201,7 +3198,7 @@ regular_loop: case 83: /* Line 1787 of yacc.c */ -#line 1147 "awkgram.y" +#line 1144 "awkgram.y" { (yyval) = mk_condition((yyvsp[(3) - (9)]), (yyvsp[(1) - (9)]), (yyvsp[(6) - (9)]), (yyvsp[(7) - (9)]), (yyvsp[(9) - (9)])); } @@ -3209,13 +3206,13 @@ regular_loop: case 88: /* Line 1787 of yacc.c */ -#line 1164 "awkgram.y" +#line 1161 "awkgram.y" { (yyval) = NULL; } break; case 89: /* Line 1787 of yacc.c */ -#line 1166 "awkgram.y" +#line 1163 "awkgram.y" { bcfree((yyvsp[(1) - (2)])); (yyval) = (yyvsp[(2) - (2)]); @@ -3224,7 +3221,7 @@ regular_loop: case 92: /* Line 1787 of yacc.c */ -#line 1179 "awkgram.y" +#line 1176 "awkgram.y" { append_param((yyvsp[(1) - (1)])->lextok); (yyvsp[(1) - (1)])->lextok = NULL; @@ -3234,7 +3231,7 @@ regular_loop: case 93: /* Line 1787 of yacc.c */ -#line 1185 "awkgram.y" +#line 1182 "awkgram.y" { append_param((yyvsp[(3) - (3)])->lextok); (yyvsp[(3) - (3)])->lextok = NULL; @@ -3245,55 +3242,55 @@ regular_loop: case 94: /* Line 1787 of yacc.c */ -#line 1192 "awkgram.y" +#line 1189 "awkgram.y" { /* func_params = NULL; */ } break; case 95: /* Line 1787 of yacc.c */ -#line 1194 "awkgram.y" +#line 1191 "awkgram.y" { /* func_params = NULL; */ } break; case 96: /* Line 1787 of yacc.c */ -#line 1196 "awkgram.y" +#line 1193 "awkgram.y" { /* func_params = NULL; */ } break; case 97: /* Line 1787 of yacc.c */ -#line 1202 "awkgram.y" +#line 1199 "awkgram.y" { (yyval) = NULL; } break; case 98: /* Line 1787 of yacc.c */ -#line 1204 "awkgram.y" +#line 1201 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 99: /* Line 1787 of yacc.c */ -#line 1209 "awkgram.y" +#line 1206 "awkgram.y" { (yyval) = NULL; } break; case 100: /* Line 1787 of yacc.c */ -#line 1211 "awkgram.y" +#line 1208 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 101: /* Line 1787 of yacc.c */ -#line 1216 "awkgram.y" +#line 1213 "awkgram.y" { (yyval) = mk_expression_list(NULL, (yyvsp[(1) - (1)])); } break; case 102: /* Line 1787 of yacc.c */ -#line 1218 "awkgram.y" +#line 1215 "awkgram.y" { (yyval) = mk_expression_list((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); yyerrok; @@ -3302,31 +3299,31 @@ regular_loop: case 103: /* Line 1787 of yacc.c */ -#line 1223 "awkgram.y" +#line 1220 "awkgram.y" { (yyval) = NULL; } break; case 104: /* Line 1787 of yacc.c */ -#line 1225 "awkgram.y" +#line 1222 "awkgram.y" { (yyval) = NULL; } break; case 105: /* Line 1787 of yacc.c */ -#line 1227 "awkgram.y" +#line 1224 "awkgram.y" { (yyval) = NULL; } break; case 106: /* Line 1787 of yacc.c */ -#line 1229 "awkgram.y" +#line 1226 "awkgram.y" { (yyval) = NULL; } break; case 107: /* Line 1787 of yacc.c */ -#line 1235 "awkgram.y" +#line 1232 "awkgram.y" { if (do_lint && (yyvsp[(3) - (3)])->lasti->opcode == Op_match_rec) lintwarn_ln((yyvsp[(2) - (3)])->source_line, @@ -3337,19 +3334,19 @@ regular_loop: case 108: /* Line 1787 of yacc.c */ -#line 1242 "awkgram.y" +#line 1239 "awkgram.y" { (yyval) = mk_boolean((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 109: /* Line 1787 of yacc.c */ -#line 1244 "awkgram.y" +#line 1241 "awkgram.y" { (yyval) = mk_boolean((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 110: /* Line 1787 of yacc.c */ -#line 1246 "awkgram.y" +#line 1243 "awkgram.y" { if ((yyvsp[(1) - (3)])->lasti->opcode == Op_match_rec) warning_ln((yyvsp[(2) - (3)])->source_line, @@ -3369,7 +3366,7 @@ regular_loop: case 111: /* Line 1787 of yacc.c */ -#line 1262 "awkgram.y" +#line 1259 "awkgram.y" { if (do_lint_old) warning_ln((yyvsp[(2) - (3)])->source_line, @@ -3383,7 +3380,7 @@ regular_loop: case 112: /* Line 1787 of yacc.c */ -#line 1272 "awkgram.y" +#line 1269 "awkgram.y" { if (do_lint && (yyvsp[(3) - (3)])->lasti->opcode == Op_match_rec) lintwarn_ln((yyvsp[(2) - (3)])->source_line, @@ -3394,31 +3391,31 @@ regular_loop: case 113: /* Line 1787 of yacc.c */ -#line 1279 "awkgram.y" +#line 1276 "awkgram.y" { (yyval) = mk_condition((yyvsp[(1) - (5)]), (yyvsp[(2) - (5)]), (yyvsp[(3) - (5)]), (yyvsp[(4) - (5)]), (yyvsp[(5) - (5)])); } break; case 114: /* Line 1787 of yacc.c */ -#line 1281 "awkgram.y" +#line 1278 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 115: /* Line 1787 of yacc.c */ -#line 1286 "awkgram.y" +#line 1283 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 116: /* Line 1787 of yacc.c */ -#line 1288 "awkgram.y" +#line 1285 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 117: /* Line 1787 of yacc.c */ -#line 1290 "awkgram.y" +#line 1287 "awkgram.y" { (yyvsp[(2) - (2)])->opcode = Op_assign_quotient; (yyval) = (yyvsp[(2) - (2)]); @@ -3427,43 +3424,43 @@ regular_loop: case 118: /* Line 1787 of yacc.c */ -#line 1298 "awkgram.y" +#line 1295 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 119: /* Line 1787 of yacc.c */ -#line 1300 "awkgram.y" +#line 1297 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 120: /* Line 1787 of yacc.c */ -#line 1305 "awkgram.y" +#line 1302 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 121: /* Line 1787 of yacc.c */ -#line 1307 "awkgram.y" +#line 1304 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 122: /* Line 1787 of yacc.c */ -#line 1312 "awkgram.y" +#line 1309 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 123: /* Line 1787 of yacc.c */ -#line 1314 "awkgram.y" +#line 1311 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 124: /* Line 1787 of yacc.c */ -#line 1316 "awkgram.y" +#line 1313 "awkgram.y" { int count = 2; int is_simple_var = FALSE; @@ -3517,43 +3514,43 @@ regular_loop: case 126: /* 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 127: /* Line 1787 of yacc.c */ -#line 1373 "awkgram.y" +#line 1370 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 128: /* Line 1787 of yacc.c */ -#line 1375 "awkgram.y" +#line 1372 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 129: /* Line 1787 of yacc.c */ -#line 1377 "awkgram.y" +#line 1374 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 130: /* Line 1787 of yacc.c */ -#line 1379 "awkgram.y" +#line 1376 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 131: /* Line 1787 of yacc.c */ -#line 1381 "awkgram.y" +#line 1378 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 132: /* Line 1787 of yacc.c */ -#line 1383 "awkgram.y" +#line 1380 "awkgram.y" { /* * In BEGINFILE/ENDFILE, allow `getline var < file' @@ -3580,7 +3577,7 @@ regular_loop: case 133: /* Line 1787 of yacc.c */ -#line 1406 "awkgram.y" +#line 1403 "awkgram.y" { (yyvsp[(2) - (2)])->opcode = Op_postincrement; (yyval) = mk_assignment((yyvsp[(1) - (2)]), NULL, (yyvsp[(2) - (2)])); @@ -3589,7 +3586,7 @@ regular_loop: case 134: /* Line 1787 of yacc.c */ -#line 1411 "awkgram.y" +#line 1408 "awkgram.y" { (yyvsp[(2) - (2)])->opcode = Op_postdecrement; (yyval) = mk_assignment((yyvsp[(1) - (2)]), NULL, (yyvsp[(2) - (2)])); @@ -3598,7 +3595,7 @@ regular_loop: case 135: /* Line 1787 of yacc.c */ -#line 1416 "awkgram.y" +#line 1413 "awkgram.y" { if (do_lint_old) { warning_ln((yyvsp[(4) - (5)])->source_line, @@ -3622,7 +3619,7 @@ regular_loop: case 136: /* Line 1787 of yacc.c */ -#line 1441 "awkgram.y" +#line 1438 "awkgram.y" { (yyval) = mk_getline((yyvsp[(3) - (4)]), (yyvsp[(4) - (4)]), (yyvsp[(1) - (4)]), (yyvsp[(2) - (4)])->redir_type); bcfree((yyvsp[(2) - (4)])); @@ -3631,43 +3628,43 @@ regular_loop: case 137: /* 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 138: /* Line 1787 of yacc.c */ -#line 1449 "awkgram.y" +#line 1446 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 139: /* Line 1787 of yacc.c */ -#line 1451 "awkgram.y" +#line 1448 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 140: /* Line 1787 of yacc.c */ -#line 1453 "awkgram.y" +#line 1450 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 141: /* Line 1787 of yacc.c */ -#line 1455 "awkgram.y" +#line 1452 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 142: /* Line 1787 of yacc.c */ -#line 1457 "awkgram.y" +#line 1454 "awkgram.y" { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } break; case 143: /* Line 1787 of yacc.c */ -#line 1462 "awkgram.y" +#line 1459 "awkgram.y" { (yyval) = list_create((yyvsp[(1) - (1)])); } @@ -3675,7 +3672,7 @@ regular_loop: case 144: /* Line 1787 of yacc.c */ -#line 1466 "awkgram.y" +#line 1463 "awkgram.y" { if ((yyvsp[(2) - (2)])->opcode == Op_match_rec) { (yyvsp[(2) - (2)])->opcode = Op_nomatch; @@ -3710,13 +3707,13 @@ regular_loop: case 145: /* Line 1787 of yacc.c */ -#line 1497 "awkgram.y" +#line 1494 "awkgram.y" { (yyval) = (yyvsp[(2) - (3)]); } break; case 146: /* Line 1787 of yacc.c */ -#line 1499 "awkgram.y" +#line 1496 "awkgram.y" { (yyval) = snode((yyvsp[(3) - (4)]), (yyvsp[(1) - (4)])); if ((yyval) == NULL) @@ -3726,7 +3723,7 @@ regular_loop: case 147: /* Line 1787 of yacc.c */ -#line 1505 "awkgram.y" +#line 1502 "awkgram.y" { (yyval) = snode((yyvsp[(3) - (4)]), (yyvsp[(1) - (4)])); if ((yyval) == NULL) @@ -3736,7 +3733,7 @@ regular_loop: case 148: /* Line 1787 of yacc.c */ -#line 1511 "awkgram.y" +#line 1508 "awkgram.y" { static short warned1 = FALSE; @@ -3753,7 +3750,7 @@ regular_loop: case 151: /* Line 1787 of yacc.c */ -#line 1526 "awkgram.y" +#line 1523 "awkgram.y" { (yyvsp[(1) - (2)])->opcode = Op_preincrement; (yyval) = mk_assignment((yyvsp[(2) - (2)]), NULL, (yyvsp[(1) - (2)])); @@ -3762,7 +3759,7 @@ regular_loop: case 152: /* Line 1787 of yacc.c */ -#line 1531 "awkgram.y" +#line 1528 "awkgram.y" { (yyvsp[(1) - (2)])->opcode = Op_predecrement; (yyval) = mk_assignment((yyvsp[(2) - (2)]), NULL, (yyvsp[(1) - (2)])); @@ -3771,7 +3768,7 @@ regular_loop: case 153: /* Line 1787 of yacc.c */ -#line 1536 "awkgram.y" +#line 1533 "awkgram.y" { (yyval) = list_create((yyvsp[(1) - (1)])); } @@ -3779,7 +3776,7 @@ regular_loop: case 154: /* Line 1787 of yacc.c */ -#line 1540 "awkgram.y" +#line 1537 "awkgram.y" { (yyval) = list_create((yyvsp[(1) - (1)])); } @@ -3787,7 +3784,7 @@ regular_loop: case 155: /* Line 1787 of yacc.c */ -#line 1544 "awkgram.y" +#line 1541 "awkgram.y" { if ((yyvsp[(2) - (2)])->lasti->opcode == Op_push_i && ((yyvsp[(2) - (2)])->lasti->memory->flags & (STRCUR|STRING)) == 0) { @@ -3803,7 +3800,7 @@ regular_loop: case 156: /* Line 1787 of yacc.c */ -#line 1556 "awkgram.y" +#line 1553 "awkgram.y" { /* * was: $$ = $2 @@ -3817,7 +3814,7 @@ regular_loop: case 157: /* Line 1787 of yacc.c */ -#line 1569 "awkgram.y" +#line 1566 "awkgram.y" { func_use((yyvsp[(1) - (1)])->lasti->func_name, FUNC_USE); (yyval) = (yyvsp[(1) - (1)]); @@ -3826,7 +3823,7 @@ regular_loop: case 158: /* Line 1787 of yacc.c */ -#line 1574 "awkgram.y" +#line 1571 "awkgram.y" { /* indirect function call */ INSTRUCTION *f, *t; @@ -3863,7 +3860,7 @@ regular_loop: case 159: /* Line 1787 of yacc.c */ -#line 1610 "awkgram.y" +#line 1607 "awkgram.y" { param_sanity((yyvsp[(3) - (4)])); (yyvsp[(1) - (4)])->opcode = Op_func_call; @@ -3881,37 +3878,37 @@ regular_loop: case 160: /* Line 1787 of yacc.c */ -#line 1627 "awkgram.y" +#line 1624 "awkgram.y" { (yyval) = NULL; } break; case 161: /* Line 1787 of yacc.c */ -#line 1629 "awkgram.y" +#line 1626 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 162: /* Line 1787 of yacc.c */ -#line 1634 "awkgram.y" +#line 1631 "awkgram.y" { (yyval) = NULL; } break; case 163: /* Line 1787 of yacc.c */ -#line 1636 "awkgram.y" +#line 1633 "awkgram.y" { (yyval) = (yyvsp[(1) - (2)]); } break; case 164: /* Line 1787 of yacc.c */ -#line 1641 "awkgram.y" +#line 1638 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 165: /* Line 1787 of yacc.c */ -#line 1643 "awkgram.y" +#line 1640 "awkgram.y" { (yyval) = list_merge((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); } @@ -3919,7 +3916,7 @@ regular_loop: case 166: /* Line 1787 of yacc.c */ -#line 1650 "awkgram.y" +#line 1647 "awkgram.y" { INSTRUCTION *ip = (yyvsp[(1) - (1)])->lasti; int count = ip->sub_count; /* # of SUBSEP-seperated expressions */ @@ -3937,7 +3934,7 @@ regular_loop: case 167: /* Line 1787 of yacc.c */ -#line 1667 "awkgram.y" +#line 1664 "awkgram.y" { INSTRUCTION *t = (yyvsp[(2) - (3)]); if ((yyvsp[(2) - (3)]) == NULL) { @@ -3955,13 +3952,13 @@ regular_loop: case 168: /* Line 1787 of yacc.c */ -#line 1684 "awkgram.y" +#line 1681 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 169: /* Line 1787 of yacc.c */ -#line 1686 "awkgram.y" +#line 1683 "awkgram.y" { (yyval) = list_merge((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); } @@ -3969,13 +3966,13 @@ regular_loop: case 170: /* Line 1787 of yacc.c */ -#line 1693 "awkgram.y" +#line 1690 "awkgram.y" { (yyval) = (yyvsp[(1) - (2)]); } break; case 171: /* Line 1787 of yacc.c */ -#line 1698 "awkgram.y" +#line 1695 "awkgram.y" { char *var_name = (yyvsp[(1) - (1)])->lextok; @@ -3987,7 +3984,7 @@ regular_loop: case 172: /* Line 1787 of yacc.c */ -#line 1706 "awkgram.y" +#line 1703 "awkgram.y" { NODE *n; @@ -4002,7 +3999,7 @@ regular_loop: case 173: /* Line 1787 of yacc.c */ -#line 1720 "awkgram.y" +#line 1717 "awkgram.y" { INSTRUCTION *ip = (yyvsp[(1) - (1)])->nexti; if (ip->opcode == Op_push @@ -4018,7 +4015,7 @@ regular_loop: case 174: /* Line 1787 of yacc.c */ -#line 1732 "awkgram.y" +#line 1729 "awkgram.y" { (yyval) = list_append((yyvsp[(2) - (3)]), (yyvsp[(1) - (3)])); if ((yyvsp[(3) - (3)]) != NULL) @@ -4028,7 +4025,7 @@ regular_loop: case 175: /* Line 1787 of yacc.c */ -#line 1741 "awkgram.y" +#line 1738 "awkgram.y" { (yyvsp[(1) - (1)])->opcode = Op_postincrement; } @@ -4036,7 +4033,7 @@ regular_loop: case 176: /* Line 1787 of yacc.c */ -#line 1745 "awkgram.y" +#line 1742 "awkgram.y" { (yyvsp[(1) - (1)])->opcode = Op_postdecrement; } @@ -4044,43 +4041,43 @@ regular_loop: case 177: /* Line 1787 of yacc.c */ -#line 1748 "awkgram.y" +#line 1745 "awkgram.y" { (yyval) = NULL; } break; case 179: /* Line 1787 of yacc.c */ -#line 1756 "awkgram.y" +#line 1753 "awkgram.y" { yyerrok; } break; case 180: /* Line 1787 of yacc.c */ -#line 1760 "awkgram.y" +#line 1757 "awkgram.y" { yyerrok; } break; case 183: /* Line 1787 of yacc.c */ -#line 1769 "awkgram.y" +#line 1766 "awkgram.y" { yyerrok; } break; case 184: /* Line 1787 of yacc.c */ -#line 1773 "awkgram.y" +#line 1770 "awkgram.y" { (yyval) = (yyvsp[(1) - (1)]); yyerrok; } break; case 185: /* Line 1787 of yacc.c */ -#line 1777 "awkgram.y" +#line 1774 "awkgram.y" { yyerrok; } break; /* Line 1787 of yacc.c */ -#line 4096 "awkgram.c" +#line 4093 "awkgram.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -4310,7 +4307,7 @@ yyreturn: /* Line 2048 of yacc.c */ -#line 1779 "awkgram.y" +#line 1776 "awkgram.y" struct token { @@ -4400,7 +4397,7 @@ static const struct token tokentab[] = { {"match", Op_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_match}, {"mktime", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_mktime}, {"next", Op_K_next, LEX_NEXT, 0, 0}, -{"nextfile", Op_K_nextfile, LEX_NEXTFILE, GAWKX, 0}, +{"nextfile", Op_K_nextfile, LEX_NEXTFILE, 0, 0}, {"or", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_or}, {"patsplit", Op_builtin, LEX_BUILTIN, GAWKX|A(2)|A(3)|A(4), do_patsplit}, {"print", Op_K_print, LEX_PRINT, 0, 0}, @@ -831,10 +831,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, @@ -987,16 +983,17 @@ simple_stmt $2->memory = variable(arr, Node_var_new); if ($4 == NULL) { - static short 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 { @@ -1020,7 +1017,7 @@ simple_stmt } 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(arr, Node_var_new); $3->opcode = Op_push_array; @@ -1865,7 +1862,7 @@ static const struct token tokentab[] = { {"match", Op_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_match}, {"mktime", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_mktime}, {"next", Op_K_next, LEX_NEXT, 0, 0}, -{"nextfile", Op_K_nextfile, LEX_NEXTFILE, GAWKX, 0}, +{"nextfile", Op_K_nextfile, LEX_NEXTFILE, 0, 0}, {"or", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_or}, {"patsplit", Op_builtin, LEX_BUILTIN, GAWKX|A(2)|A(3)|A(4), do_patsplit}, {"print", Op_K_print, LEX_PRINT, 0, 0}, diff --git a/doc/ChangeLog b/doc/ChangeLog index f279986c..30bae7e0 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-08-12 Arnold D. Robbins <arnold@skeeve.com> * gawk.texi (Ranges and Locales): Clarified ranges and diff --git a/doc/awkcard.in b/doc/awkcard.in index fa45fe34..65f36b4e 100644 --- a/doc/awkcard.in +++ b/doc/awkcard.in @@ -686,7 +686,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 @@ -900,7 +900,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) { @@ -1285,15 +1285,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 275188ef..30ff2c26 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -8948,37 +8948,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::. @@ -8989,6 +8987,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::). @@ -10105,18 +10108,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) @@ -25263,7 +25270,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) @@ -26040,7 +26047,7 @@ Index * functions, user-defined, counts: Profiling. (line 132) * 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 81) @@ -26554,7 +26561,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: Dgawk Execution Control. (line 49) * NF variable <1>: Auto-set. (line 107) @@ -26743,7 +26750,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) @@ -27149,7 +27156,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) @@ -27654,242 +27661,242 @@ Node: Break Statement372503 Node: Continue Statement374493 Node: Next Statement376286 Node: Nextfile Statement378676 -Node: Exit Statement381221 -Node: Built-in Variables383637 -Node: User-modified384732 -Ref: User-modified-Footnote-1392758 -Node: Auto-set392820 -Ref: Auto-set-Footnote-1402111 -Node: ARGC and ARGV402316 -Node: Arrays406167 -Node: Array Basics407672 -Node: Array Intro408498 -Node: Reference to Elements412816 -Node: Assigning Elements415086 -Node: Array Example415577 -Node: Scanning an Array417309 -Node: Controlling Scanning419623 -Ref: Controlling Scanning-Footnote-1424556 -Node: Delete424872 -Ref: Delete-Footnote-1427307 -Node: Numeric Array Subscripts427364 -Node: Uninitialized Subscripts429547 -Node: Multi-dimensional431175 -Node: Multi-scanning434269 -Node: Arrays of Arrays435860 -Node: Functions440505 -Node: Built-in441327 -Node: Calling Built-in442405 -Node: Numeric Functions444393 -Ref: Numeric Functions-Footnote-1448225 -Ref: Numeric Functions-Footnote-2448582 -Ref: Numeric Functions-Footnote-3448630 -Node: String Functions448899 -Ref: String Functions-Footnote-1472396 -Ref: String Functions-Footnote-2472525 -Ref: String Functions-Footnote-3472773 -Node: Gory Details472860 -Ref: table-sub-escapes474539 -Ref: table-sub-posix-92475893 -Ref: table-sub-proposed477236 -Ref: table-posix-sub478586 -Ref: table-gensub-escapes480132 -Ref: Gory Details-Footnote-1481339 -Ref: Gory Details-Footnote-2481390 -Node: I/O Functions481541 -Ref: I/O Functions-Footnote-1488196 -Node: Time Functions488343 -Ref: Time Functions-Footnote-1499235 -Ref: Time Functions-Footnote-2499303 -Ref: Time Functions-Footnote-3499461 -Ref: Time Functions-Footnote-4499572 -Ref: Time Functions-Footnote-5499684 -Ref: Time Functions-Footnote-6499911 -Node: Bitwise Functions500177 -Ref: table-bitwise-ops500735 -Ref: Bitwise Functions-Footnote-1504895 -Node: Type Functions505079 -Node: I18N Functions505549 -Node: User-defined507176 -Node: Definition Syntax507980 -Ref: Definition Syntax-Footnote-1512890 -Node: Function Example512959 -Node: Function Caveats515553 -Node: Calling A Function515974 -Node: Variable Scope517089 -Node: Pass By Value/Reference519064 -Node: Return Statement522504 -Node: Dynamic Typing525485 -Node: Indirect Calls526220 -Node: Internationalization535905 -Node: I18N and L10N537331 -Node: Explaining gettext538017 -Ref: Explaining gettext-Footnote-1543083 -Ref: Explaining gettext-Footnote-2543267 -Node: Programmer i18n543432 -Node: Translator i18n547632 -Node: String Extraction548425 -Ref: String Extraction-Footnote-1549386 -Node: Printf Ordering549472 -Ref: Printf Ordering-Footnote-1552256 -Node: I18N Portability552320 -Ref: I18N Portability-Footnote-1554769 -Node: I18N Example554832 -Ref: I18N Example-Footnote-1557467 -Node: Gawk I18N557539 -Node: Advanced Features558156 -Node: Nondecimal Data559669 -Node: Array Sorting561252 -Node: Controlling Array Traversal561949 -Node: Array Sorting Functions570186 -Ref: Array Sorting Functions-Footnote-1573860 -Ref: Array Sorting Functions-Footnote-2573953 -Node: Two-way I/O574147 -Ref: Two-way I/O-Footnote-1579579 -Node: TCP/IP Networking579649 -Node: Profiling582493 -Node: Library Functions589967 -Ref: Library Functions-Footnote-1592974 -Node: Library Names593145 -Ref: Library Names-Footnote-1596616 -Ref: Library Names-Footnote-2596836 -Node: General Functions596922 -Node: Strtonum Function597875 -Node: Assert Function600805 -Node: Round Function604131 -Node: Cliff Random Function605674 -Node: Ordinal Functions606690 -Ref: Ordinal Functions-Footnote-1609760 -Ref: Ordinal Functions-Footnote-2610012 -Node: Join Function610221 -Ref: Join Function-Footnote-1611992 -Node: Gettimeofday Function612192 -Node: Data File Management615907 -Node: Filetrans Function616539 -Node: Rewind Function620678 -Node: File Checking622065 -Node: Empty Files623159 -Node: Ignoring Assigns625389 -Node: Getopt Function626942 -Ref: Getopt Function-Footnote-1638246 -Node: Passwd Functions638449 -Ref: Passwd Functions-Footnote-1647424 -Node: Group Functions647512 -Node: Walking Arrays655596 -Node: Sample Programs657165 -Node: Running Examples657830 -Node: Clones658558 -Node: Cut Program659782 -Node: Egrep Program669627 -Ref: Egrep Program-Footnote-1677400 -Node: Id Program677510 -Node: Split Program681126 -Ref: Split Program-Footnote-1684645 -Node: Tee Program684773 -Node: Uniq Program687576 -Node: Wc Program695005 -Ref: Wc Program-Footnote-1699271 -Ref: Wc Program-Footnote-2699471 -Node: Miscellaneous Programs699563 -Node: Dupword Program700751 -Node: Alarm Program702782 -Node: Translate Program707531 -Ref: Translate Program-Footnote-1711918 -Ref: Translate Program-Footnote-2712146 -Node: Labels Program712280 -Ref: Labels Program-Footnote-1715651 -Node: Word Sorting715735 -Node: History Sorting719619 -Node: Extract Program721458 -Ref: Extract Program-Footnote-1728941 -Node: Simple Sed729069 -Node: Igawk Program732131 -Ref: Igawk Program-Footnote-1747288 -Ref: Igawk Program-Footnote-2747489 -Node: Anagram Program747627 -Node: Signature Program750695 -Node: Debugger751795 -Node: Debugging752706 -Node: Debugging Concepts753119 -Node: Debugging Terms754975 -Node: Awk Debugging757598 -Node: Sample dgawk session758490 -Node: dgawk invocation758982 -Node: Finding The Bug760164 -Node: List of Debugger Commands766650 -Node: Breakpoint Control767961 -Node: Dgawk Execution Control771597 -Node: Viewing And Changing Data774948 -Node: Dgawk Stack778285 -Node: Dgawk Info779745 -Node: Miscellaneous Dgawk Commands783693 -Node: Readline Support789121 -Node: Dgawk Limitations789959 -Node: Language History792148 -Node: V7/SVR3.1793660 -Node: SVR4795981 -Node: POSIX797423 -Node: BTL798431 -Node: POSIX/GNU799165 -Node: Common Extensions804316 -Node: Ranges and Locales805423 -Ref: Ranges and Locales-Footnote-1810041 -Ref: Ranges and Locales-Footnote-2810068 -Ref: Ranges and Locales-Footnote-3810328 -Node: Contributors810549 -Node: Installation814811 -Node: Gawk Distribution815705 -Node: Getting816189 -Node: Extracting817015 -Node: Distribution contents818707 -Node: Unix Installation823929 -Node: Quick Installation824546 -Node: Additional Configuration Options826508 -Node: Configuration Philosophy827985 -Node: Non-Unix Installation830327 -Node: PC Installation830785 -Node: PC Binary Installation832084 -Node: PC Compiling834099 -Node: PC Testing837043 -Node: PC Using838219 -Node: Cygwin842404 -Node: MSYS843404 -Node: VMS Installation843918 -Node: VMS Compilation844521 -Ref: VMS Compilation-Footnote-1845528 -Node: VMS Installation Details845586 -Node: VMS Running847221 -Node: VMS Old Gawk848828 -Node: Bugs849302 -Node: Other Versions853154 -Node: Notes858435 -Node: Compatibility Mode859127 -Node: Additions859910 -Node: Accessing The Source860722 -Node: Adding Code862147 -Node: New Ports868114 -Node: Dynamic Extensions872227 -Node: Internals873603 -Node: Plugin License882706 -Node: Sample Library883340 -Node: Internal File Description884026 -Node: Internal File Ops887741 -Ref: Internal File Ops-Footnote-1892522 -Node: Using Internal File Ops892662 -Node: Future Extensions895039 -Node: Basic Concepts897543 -Node: Basic High Level898300 -Ref: Basic High Level-Footnote-1902335 -Node: Basic Data Typing902520 -Node: Floating Point Issues907045 -Node: String Conversion Precision908128 -Ref: String Conversion Precision-Footnote-1909828 -Node: Unexpected Results909937 -Node: POSIX Floating Point Problems911763 -Ref: POSIX Floating Point Problems-Footnote-1915468 -Node: Glossary915506 -Node: Copying940482 -Node: GNU Free Documentation License978039 -Node: Index1003176 +Node: Exit Statement381317 +Node: Built-in Variables383733 +Node: User-modified384828 +Ref: User-modified-Footnote-1392854 +Node: Auto-set392916 +Ref: Auto-set-Footnote-1402207 +Node: ARGC and ARGV402412 +Node: Arrays406263 +Node: Array Basics407768 +Node: Array Intro408594 +Node: Reference to Elements412912 +Node: Assigning Elements415182 +Node: Array Example415673 +Node: Scanning an Array417405 +Node: Controlling Scanning419719 +Ref: Controlling Scanning-Footnote-1424652 +Node: Delete424968 +Ref: Delete-Footnote-1427733 +Node: Numeric Array Subscripts427790 +Node: Uninitialized Subscripts429973 +Node: Multi-dimensional431601 +Node: Multi-scanning434695 +Node: Arrays of Arrays436286 +Node: Functions440931 +Node: Built-in441753 +Node: Calling Built-in442831 +Node: Numeric Functions444819 +Ref: Numeric Functions-Footnote-1448651 +Ref: Numeric Functions-Footnote-2449008 +Ref: Numeric Functions-Footnote-3449056 +Node: String Functions449325 +Ref: String Functions-Footnote-1472822 +Ref: String Functions-Footnote-2472951 +Ref: String Functions-Footnote-3473199 +Node: Gory Details473286 +Ref: table-sub-escapes474965 +Ref: table-sub-posix-92476319 +Ref: table-sub-proposed477662 +Ref: table-posix-sub479012 +Ref: table-gensub-escapes480558 +Ref: Gory Details-Footnote-1481765 +Ref: Gory Details-Footnote-2481816 +Node: I/O Functions481967 +Ref: I/O Functions-Footnote-1488622 +Node: Time Functions488769 +Ref: Time Functions-Footnote-1499661 +Ref: Time Functions-Footnote-2499729 +Ref: Time Functions-Footnote-3499887 +Ref: Time Functions-Footnote-4499998 +Ref: Time Functions-Footnote-5500110 +Ref: Time Functions-Footnote-6500337 +Node: Bitwise Functions500603 +Ref: table-bitwise-ops501161 +Ref: Bitwise Functions-Footnote-1505321 +Node: Type Functions505505 +Node: I18N Functions505975 +Node: User-defined507602 +Node: Definition Syntax508406 +Ref: Definition Syntax-Footnote-1513316 +Node: Function Example513385 +Node: Function Caveats515979 +Node: Calling A Function516400 +Node: Variable Scope517515 +Node: Pass By Value/Reference519490 +Node: Return Statement522930 +Node: Dynamic Typing525911 +Node: Indirect Calls526646 +Node: Internationalization536331 +Node: I18N and L10N537757 +Node: Explaining gettext538443 +Ref: Explaining gettext-Footnote-1543509 +Ref: Explaining gettext-Footnote-2543693 +Node: Programmer i18n543858 +Node: Translator i18n548058 +Node: String Extraction548851 +Ref: String Extraction-Footnote-1549812 +Node: Printf Ordering549898 +Ref: Printf Ordering-Footnote-1552682 +Node: I18N Portability552746 +Ref: I18N Portability-Footnote-1555195 +Node: I18N Example555258 +Ref: I18N Example-Footnote-1557893 +Node: Gawk I18N557965 +Node: Advanced Features558582 +Node: Nondecimal Data560095 +Node: Array Sorting561678 +Node: Controlling Array Traversal562375 +Node: Array Sorting Functions570612 +Ref: Array Sorting Functions-Footnote-1574286 +Ref: Array Sorting Functions-Footnote-2574379 +Node: Two-way I/O574573 +Ref: Two-way I/O-Footnote-1580005 +Node: TCP/IP Networking580075 +Node: Profiling582919 +Node: Library Functions590393 +Ref: Library Functions-Footnote-1593400 +Node: Library Names593571 +Ref: Library Names-Footnote-1597042 +Ref: Library Names-Footnote-2597262 +Node: General Functions597348 +Node: Strtonum Function598301 +Node: Assert Function601231 +Node: Round Function604557 +Node: Cliff Random Function606100 +Node: Ordinal Functions607116 +Ref: Ordinal Functions-Footnote-1610186 +Ref: Ordinal Functions-Footnote-2610438 +Node: Join Function610647 +Ref: Join Function-Footnote-1612418 +Node: Gettimeofday Function612618 +Node: Data File Management616333 +Node: Filetrans Function616965 +Node: Rewind Function621104 +Node: File Checking622491 +Node: Empty Files623585 +Node: Ignoring Assigns625815 +Node: Getopt Function627368 +Ref: Getopt Function-Footnote-1638672 +Node: Passwd Functions638875 +Ref: Passwd Functions-Footnote-1647850 +Node: Group Functions647938 +Node: Walking Arrays656022 +Node: Sample Programs657591 +Node: Running Examples658256 +Node: Clones658984 +Node: Cut Program660208 +Node: Egrep Program670053 +Ref: Egrep Program-Footnote-1677826 +Node: Id Program677936 +Node: Split Program681552 +Ref: Split Program-Footnote-1685071 +Node: Tee Program685199 +Node: Uniq Program688002 +Node: Wc Program695431 +Ref: Wc Program-Footnote-1699697 +Ref: Wc Program-Footnote-2699897 +Node: Miscellaneous Programs699989 +Node: Dupword Program701177 +Node: Alarm Program703208 +Node: Translate Program707957 +Ref: Translate Program-Footnote-1712344 +Ref: Translate Program-Footnote-2712572 +Node: Labels Program712706 +Ref: Labels Program-Footnote-1716077 +Node: Word Sorting716161 +Node: History Sorting720045 +Node: Extract Program721884 +Ref: Extract Program-Footnote-1729367 +Node: Simple Sed729495 +Node: Igawk Program732557 +Ref: Igawk Program-Footnote-1747714 +Ref: Igawk Program-Footnote-2747915 +Node: Anagram Program748053 +Node: Signature Program751121 +Node: Debugger752221 +Node: Debugging753132 +Node: Debugging Concepts753545 +Node: Debugging Terms755401 +Node: Awk Debugging758024 +Node: Sample dgawk session758916 +Node: dgawk invocation759408 +Node: Finding The Bug760590 +Node: List of Debugger Commands767076 +Node: Breakpoint Control768387 +Node: Dgawk Execution Control772023 +Node: Viewing And Changing Data775374 +Node: Dgawk Stack778711 +Node: Dgawk Info780171 +Node: Miscellaneous Dgawk Commands784119 +Node: Readline Support789547 +Node: Dgawk Limitations790385 +Node: Language History792574 +Node: V7/SVR3.1794086 +Node: SVR4796407 +Node: POSIX797849 +Node: BTL798857 +Node: POSIX/GNU799591 +Node: Common Extensions804742 +Node: Ranges and Locales805849 +Ref: Ranges and Locales-Footnote-1810467 +Ref: Ranges and Locales-Footnote-2810494 +Ref: Ranges and Locales-Footnote-3810754 +Node: Contributors810975 +Node: Installation815237 +Node: Gawk Distribution816131 +Node: Getting816615 +Node: Extracting817441 +Node: Distribution contents819133 +Node: Unix Installation824355 +Node: Quick Installation824972 +Node: Additional Configuration Options826934 +Node: Configuration Philosophy828411 +Node: Non-Unix Installation830753 +Node: PC Installation831211 +Node: PC Binary Installation832510 +Node: PC Compiling834525 +Node: PC Testing837469 +Node: PC Using838645 +Node: Cygwin842830 +Node: MSYS843830 +Node: VMS Installation844344 +Node: VMS Compilation844947 +Ref: VMS Compilation-Footnote-1845954 +Node: VMS Installation Details846012 +Node: VMS Running847647 +Node: VMS Old Gawk849254 +Node: Bugs849728 +Node: Other Versions853580 +Node: Notes858861 +Node: Compatibility Mode859553 +Node: Additions860336 +Node: Accessing The Source861148 +Node: Adding Code862573 +Node: New Ports868540 +Node: Dynamic Extensions872653 +Node: Internals874029 +Node: Plugin License883132 +Node: Sample Library883766 +Node: Internal File Description884452 +Node: Internal File Ops888167 +Ref: Internal File Ops-Footnote-1892948 +Node: Using Internal File Ops893088 +Node: Future Extensions895465 +Node: Basic Concepts897969 +Node: Basic High Level898726 +Ref: Basic High Level-Footnote-1902761 +Node: Basic Data Typing902946 +Node: Floating Point Issues907471 +Node: String Conversion Precision908554 +Ref: String Conversion Precision-Footnote-1910254 +Node: Unexpected Results910363 +Node: POSIX Floating Point Problems912189 +Ref: POSIX Floating Point Problems-Footnote-1915894 +Node: Glossary915932 +Node: Copying940908 +Node: GNU Free Documentation License978465 +Node: Index1003602 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 1ff75230..ab9ebf86 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -12155,44 +12155,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}. @@ -12203,6 +12205,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 @@ -13664,21 +13673,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 f88b7963..1575d493 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2012-09-23 Arnold D. Robbins <arnold@skeeve.com> + + * lintwarn.ok: Updated. + 2012-08-26 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (charasbytes): Revise test to canonicalize 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 |