[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gawk-diffs] [SCM] gawk branch, gawk-4.0-stable, updated. 452f4efefd5511
From: |
Arnold Robbins |
Subject: |
[gawk-diffs] [SCM] gawk branch, gawk-4.0-stable, updated. 452f4efefd5511bc7dbe95b0167b10b403cdcf45 |
Date: |
Tue, 26 Jul 2011 03:06:42 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".
The branch, gawk-4.0-stable has been updated
via 452f4efefd5511bc7dbe95b0167b10b403cdcf45 (commit)
from fc02808c31a55f1559143ad9d8ad50e2f71a512b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=452f4efefd5511bc7dbe95b0167b10b403cdcf45
commit 452f4efefd5511bc7dbe95b0167b10b403cdcf45
Author: Arnold D. Robbins <address@hidden>
Date: Tue Jul 26 06:05:42 2011 +0300
Fix gsub and getline pass by reference. Add tests.
diff --git a/ChangeLog b/ChangeLog
index 60239f5..bde19e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2011-07-26 John Haque <address@hidden>
+
+ Fix handling of assign routines for 'getline var'.
+ Rework the previous fix for (g)sub.
+
+ * awk.h: New define assign_ctxt for use in Op_var_assign
+ and Op_field_assign opcodes. Remove define AFTER_ASSIGN.
+ * awkgram.y (snode, mk_getline): Initialize assign_ctxt.
+ * builtin.c (do_sub): Adjust to take only the first two
+ arguments.
+ * eval.c (r_interpret): In cases Op_var_assign and Op_field_assign,
+ skip the routine as appropriate. Adjust case Op_sub_builtin.
+ * main.c (get_spec_varname): New function.
+ * debug.c (print_instruction): Use the new function to get
+ special variable name.
+
2011-07-17 Arnold D. Robbins <address@hidden>
* main.c (varinit): Mark FPAT as NON_STANDARD. Thanks to
diff --git a/FUTURES b/FUTURES
index f5562f4..0257410 100644
--- a/FUTURES
+++ b/FUTURES
@@ -22,6 +22,8 @@ For 4.1
Merge xmlgawk XML extensions
+ Integrate MPFR to provide high precision arithmetic.
+
Continue code reviews / code cleanup
For 4.2
diff --git a/awk.h b/awk.h
index d9da3b9..1421203 100644
--- a/awk.h
+++ b/awk.h
@@ -631,10 +631,7 @@ typedef struct exp_instruction {
#define sub_flags d.dl
#define GSUB 0x01 /* builtin is gsub */
#define GENSUB 0x02 /* builtin is gensub */
-#define AFTER_ASSIGN 0x04 /* (g)sub target is a field or a special var
with
- * set_XX routine.
- */
-#define LITERAL 0x08 /* target is a literal string */
+#define LITERAL 0x04 /* target is a literal string */
/* Op_K_exit */
@@ -717,6 +714,9 @@ typedef struct exp_instruction {
/* Op_field_assign */
#define field_assign x.aptr
+/* Op_field_assign, Op_var_assign */
+#define assign_ctxt d.dl
+
/* Op_concat */
#define concat_flag d.dl
#define CSUBSEP 1
@@ -1192,7 +1192,7 @@ extern NODE *do_cos(int nargs);
extern NODE *do_rand(int nargs);
extern NODE *do_srand(int nargs);
extern NODE *do_match(int nargs);
-extern NODE *do_sub(int nargs, unsigned int flags, int *num_matches);
+extern NODE *do_sub(int nargs, unsigned int flags);
extern NODE *format_tree(const char *, size_t, NODE **, long);
extern NODE *do_lshift(int nargs);
extern NODE *do_rshift(int nargs);
diff --git a/awkgram.c b/awkgram.c
index 876821d..6471150 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -733,21 +733,21 @@ static const yytype_uint16 yyrline[] =
265, 273, 281, 283, 289, 290, 292, 318, 329, 340,
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, 783, 790, 797, 807,
- 816, 825, 834, 849, 865, 864, 876, 888, 888, 984,
- 984, 1009, 1032, 1038, 1039, 1045, 1046, 1053, 1058, 1070,
- 1084, 1086, 1092, 1097, 1099, 1107, 1109, 1118, 1119, 1127,
- 1132, 1132, 1143, 1147, 1155, 1156, 1159, 1161, 1166, 1167,
- 1174, 1176, 1180, 1186, 1193, 1195, 1197, 1204, 1205, 1211,
- 1212, 1217, 1219, 1224, 1226, 1228, 1230, 1236, 1243, 1245,
- 1247, 1263, 1273, 1280, 1282, 1287, 1289, 1291, 1299, 1301,
- 1306, 1308, 1313, 1315, 1317, 1370, 1372, 1374, 1376, 1378,
- 1380, 1382, 1384, 1407, 1412, 1417, 1442, 1448, 1450, 1452,
- 1454, 1456, 1458, 1463, 1467, 1498, 1500, 1506, 1512, 1525,
- 1526, 1527, 1532, 1537, 1541, 1545, 1557, 1570, 1575, 1611,
- 1629, 1630, 1636, 1637, 1642, 1644, 1651, 1668, 1685, 1687,
- 1694, 1699, 1707, 1721, 1734, 1743, 1747, 1751, 1755, 1759,
- 1763, 1766, 1768, 1772, 1776, 1780
+ 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
};
#endif
@@ -2733,7 +2733,6 @@ regular_loop:
/* add update_FOO instruction if necessary */
if ((yyvsp[(4) - (8)])->array_var->type == Node_var &&
(yyvsp[(4) - (8)])->array_var->var_update) {
(void) list_append(ip,
instruction(Op_var_update));
- ip->lasti->memory = (yyvsp[(4) -
(8)])->array_var;
ip->lasti->update_var = (yyvsp[(4) -
(8)])->array_var->var_update;
}
(void) list_append(ip, (yyvsp[(4) - (8)]));
@@ -2741,7 +2740,6 @@ regular_loop:
/* add set_FOO instruction if necessary */
if ((yyvsp[(4) - (8)])->array_var->type == Node_var &&
(yyvsp[(4) - (8)])->array_var->var_assign) {
(void) list_append(ip,
instruction(Op_var_assign));
- ip->lasti->memory = (yyvsp[(4) -
(8)])->array_var;
ip->lasti->assign_var = (yyvsp[(4) -
(8)])->array_var->var_assign;
}
@@ -2768,7 +2766,7 @@ regular_loop:
case 46:
/* Line 1806 of yacc.c */
-#line 784 "awkgram.y"
+#line 782 "awkgram.y"
{
(yyval) = mk_for_loop((yyvsp[(1) - (12)]), (yyvsp[(3) - (12)]),
(yyvsp[(6) - (12)]), (yyvsp[(9) - (12)]), (yyvsp[(12) - (12)]));
@@ -2780,7 +2778,7 @@ regular_loop:
case 47:
/* Line 1806 of yacc.c */
-#line 791 "awkgram.y"
+#line 789 "awkgram.y"
{
(yyval) = mk_for_loop((yyvsp[(1) - (11)]), (yyvsp[(3) - (11)]),
(INSTRUCTION *) NULL, (yyvsp[(8) - (11)]), (yyvsp[(11) - (11)]));
@@ -2792,7 +2790,7 @@ regular_loop:
case 48:
/* Line 1806 of yacc.c */
-#line 798 "awkgram.y"
+#line 796 "awkgram.y"
{
if (do_profiling)
(yyval) = list_prepend((yyvsp[(1) - (1)]),
instruction(Op_exec_count));
@@ -2804,7 +2802,7 @@ regular_loop:
case 49:
/* Line 1806 of yacc.c */
-#line 808 "awkgram.y"
+#line 806 "awkgram.y"
{
if (! break_allowed)
error_ln((yyvsp[(1) - (2)])->source_line,
@@ -2818,7 +2816,7 @@ regular_loop:
case 50:
/* Line 1806 of yacc.c */
-#line 817 "awkgram.y"
+#line 815 "awkgram.y"
{
if (! continue_allowed)
error_ln((yyvsp[(1) - (2)])->source_line,
@@ -2832,7 +2830,7 @@ regular_loop:
case 51:
/* Line 1806 of yacc.c */
-#line 826 "awkgram.y"
+#line 824 "awkgram.y"
{
/* if inside function (rule = 0), resolve context at run-time */
if (rule && rule != Rule)
@@ -2846,7 +2844,7 @@ regular_loop:
case 52:
/* Line 1806 of yacc.c */
-#line 835 "awkgram.y"
+#line 833 "awkgram.y"
{
if (do_traditional)
error_ln((yyvsp[(1) - (2)])->source_line,
@@ -2866,7 +2864,7 @@ regular_loop:
case 53:
/* Line 1806 of yacc.c */
-#line 850 "awkgram.y"
+#line 848 "awkgram.y"
{
/* Initialize the two possible jump targets, the actual target
* is resolved at run-time.
@@ -2886,7 +2884,7 @@ regular_loop:
case 54:
/* Line 1806 of yacc.c */
-#line 865 "awkgram.y"
+#line 863 "awkgram.y"
{
if (! can_return)
yyerror(_("`return' used outside function context"));
@@ -2896,7 +2894,7 @@ regular_loop:
case 55:
/* Line 1806 of yacc.c */
-#line 868 "awkgram.y"
+#line 866 "awkgram.y"
{
if ((yyvsp[(3) - (4)]) == NULL) {
(yyval) = list_create((yyvsp[(1) - (4)]));
@@ -2910,14 +2908,14 @@ regular_loop:
case 57:
/* Line 1806 of yacc.c */
-#line 888 "awkgram.y"
+#line 886 "awkgram.y"
{ in_print = TRUE; in_parens = 0; }
break;
case 58:
/* Line 1806 of yacc.c */
-#line 889 "awkgram.y"
+#line 887 "awkgram.y"
{
/*
* Optimization: plain `print' has no expression list, so $3 is
null.
@@ -3017,14 +3015,14 @@ regular_loop:
case 59:
/* Line 1806 of yacc.c */
-#line 984 "awkgram.y"
+#line 982 "awkgram.y"
{ sub_counter = 0; }
break;
case 60:
/* Line 1806 of yacc.c */
-#line 985 "awkgram.y"
+#line 983 "awkgram.y"
{
char *arr = (yyvsp[(2) - (4)])->lextok;
@@ -3054,7 +3052,7 @@ regular_loop:
case 61:
/* Line 1806 of yacc.c */
-#line 1014 "awkgram.y"
+#line 1012 "awkgram.y"
{
static short warned = FALSE;
char *arr = (yyvsp[(3) - (4)])->lextok;
@@ -3078,35 +3076,35 @@ regular_loop:
case 62:
/* Line 1806 of yacc.c */
-#line 1033 "awkgram.y"
+#line 1031 "awkgram.y"
{ (yyval) = optimize_assignment((yyvsp[(1) - (1)])); }
break;
case 63:
/* Line 1806 of yacc.c */
-#line 1038 "awkgram.y"
+#line 1036 "awkgram.y"
{ (yyval) = NULL; }
break;
case 64:
/* Line 1806 of yacc.c */
-#line 1040 "awkgram.y"
+#line 1038 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 65:
/* Line 1806 of yacc.c */
-#line 1045 "awkgram.y"
+#line 1043 "awkgram.y"
{ (yyval) = NULL; }
break;
case 66:
/* Line 1806 of yacc.c */
-#line 1047 "awkgram.y"
+#line 1045 "awkgram.y"
{
if ((yyvsp[(1) - (2)]) == NULL)
(yyval) = list_create((yyvsp[(2) - (2)]));
@@ -3118,14 +3116,14 @@ regular_loop:
case 67:
/* Line 1806 of yacc.c */
-#line 1054 "awkgram.y"
+#line 1052 "awkgram.y"
{ (yyval) = NULL; }
break;
case 68:
/* Line 1806 of yacc.c */
-#line 1059 "awkgram.y"
+#line 1057 "awkgram.y"
{
INSTRUCTION *casestmt = (yyvsp[(5) - (5)]);
if ((yyvsp[(5) - (5)]) == NULL)
@@ -3142,7 +3140,7 @@ regular_loop:
case 69:
/* Line 1806 of yacc.c */
-#line 1071 "awkgram.y"
+#line 1069 "awkgram.y"
{
INSTRUCTION *casestmt = (yyvsp[(4) - (4)]);
if ((yyvsp[(4) - (4)]) == NULL)
@@ -3158,14 +3156,14 @@ regular_loop:
case 70:
/* Line 1806 of yacc.c */
-#line 1085 "awkgram.y"
+#line 1083 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 71:
/* Line 1806 of yacc.c */
-#line 1087 "awkgram.y"
+#line 1085 "awkgram.y"
{
(yyvsp[(2) - (2)])->memory->numbr = -(force_number((yyvsp[(2) -
(2)])->memory));
bcfree((yyvsp[(1) - (2)]));
@@ -3176,7 +3174,7 @@ regular_loop:
case 72:
/* Line 1806 of yacc.c */
-#line 1093 "awkgram.y"
+#line 1091 "awkgram.y"
{
bcfree((yyvsp[(1) - (2)]));
(yyval) = (yyvsp[(2) - (2)]);
@@ -3186,14 +3184,14 @@ regular_loop:
case 73:
/* Line 1806 of yacc.c */
-#line 1098 "awkgram.y"
+#line 1096 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 74:
/* Line 1806 of yacc.c */
-#line 1100 "awkgram.y"
+#line 1098 "awkgram.y"
{
(yyvsp[(1) - (1)])->opcode = Op_push_re;
(yyval) = (yyvsp[(1) - (1)]);
@@ -3203,21 +3201,21 @@ regular_loop:
case 75:
/* Line 1806 of yacc.c */
-#line 1108 "awkgram.y"
+#line 1106 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 76:
/* Line 1806 of yacc.c */
-#line 1110 "awkgram.y"
+#line 1108 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 78:
/* Line 1806 of yacc.c */
-#line 1120 "awkgram.y"
+#line 1118 "awkgram.y"
{
(yyval) = (yyvsp[(2) - (3)]);
}
@@ -3226,7 +3224,7 @@ regular_loop:
case 79:
/* Line 1806 of yacc.c */
-#line 1127 "awkgram.y"
+#line 1125 "awkgram.y"
{
in_print = FALSE;
in_parens = 0;
@@ -3237,14 +3235,14 @@ regular_loop:
case 80:
/* Line 1806 of yacc.c */
-#line 1132 "awkgram.y"
+#line 1130 "awkgram.y"
{ in_print = FALSE; in_parens = 0; }
break;
case 81:
/* Line 1806 of yacc.c */
-#line 1133 "awkgram.y"
+#line 1131 "awkgram.y"
{
if ((yyvsp[(1) - (3)])->redir_type == redirect_twoway
&& (yyvsp[(3) - (3)])->lasti->opcode ==
Op_K_getline_redir
@@ -3257,7 +3255,7 @@ regular_loop:
case 82:
/* Line 1806 of yacc.c */
-#line 1144 "awkgram.y"
+#line 1142 "awkgram.y"
{
(yyval) = mk_condition((yyvsp[(3) - (6)]), (yyvsp[(1) - (6)]),
(yyvsp[(6) - (6)]), NULL, NULL);
}
@@ -3266,7 +3264,7 @@ regular_loop:
case 83:
/* Line 1806 of yacc.c */
-#line 1149 "awkgram.y"
+#line 1147 "awkgram.y"
{
(yyval) = mk_condition((yyvsp[(3) - (9)]), (yyvsp[(1) - (9)]),
(yyvsp[(6) - (9)]), (yyvsp[(7) - (9)]), (yyvsp[(9) - (9)]));
}
@@ -3275,14 +3273,14 @@ regular_loop:
case 88:
/* Line 1806 of yacc.c */
-#line 1166 "awkgram.y"
+#line 1164 "awkgram.y"
{ (yyval) = NULL; }
break;
case 89:
/* Line 1806 of yacc.c */
-#line 1168 "awkgram.y"
+#line 1166 "awkgram.y"
{
bcfree((yyvsp[(1) - (2)]));
(yyval) = (yyvsp[(2) - (2)]);
@@ -3292,7 +3290,7 @@ regular_loop:
case 92:
/* Line 1806 of yacc.c */
-#line 1181 "awkgram.y"
+#line 1179 "awkgram.y"
{
append_param((yyvsp[(1) - (1)])->lextok);
(yyvsp[(1) - (1)])->lextok = NULL;
@@ -3303,7 +3301,7 @@ regular_loop:
case 93:
/* Line 1806 of yacc.c */
-#line 1187 "awkgram.y"
+#line 1185 "awkgram.y"
{
append_param((yyvsp[(3) - (3)])->lextok);
(yyvsp[(3) - (3)])->lextok = NULL;
@@ -3315,63 +3313,63 @@ regular_loop:
case 94:
/* Line 1806 of yacc.c */
-#line 1194 "awkgram.y"
+#line 1192 "awkgram.y"
{ /* func_params = NULL; */ }
break;
case 95:
/* Line 1806 of yacc.c */
-#line 1196 "awkgram.y"
+#line 1194 "awkgram.y"
{ /* func_params = NULL; */ }
break;
case 96:
/* Line 1806 of yacc.c */
-#line 1198 "awkgram.y"
+#line 1196 "awkgram.y"
{ /* func_params = NULL; */ }
break;
case 97:
/* Line 1806 of yacc.c */
-#line 1204 "awkgram.y"
+#line 1202 "awkgram.y"
{ (yyval) = NULL; }
break;
case 98:
/* Line 1806 of yacc.c */
-#line 1206 "awkgram.y"
+#line 1204 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 99:
/* Line 1806 of yacc.c */
-#line 1211 "awkgram.y"
+#line 1209 "awkgram.y"
{ (yyval) = NULL; }
break;
case 100:
/* Line 1806 of yacc.c */
-#line 1213 "awkgram.y"
+#line 1211 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 101:
/* Line 1806 of yacc.c */
-#line 1218 "awkgram.y"
+#line 1216 "awkgram.y"
{ (yyval) = mk_expression_list(NULL, (yyvsp[(1) - (1)])); }
break;
case 102:
/* Line 1806 of yacc.c */
-#line 1220 "awkgram.y"
+#line 1218 "awkgram.y"
{
(yyval) = mk_expression_list((yyvsp[(1) - (3)]), (yyvsp[(3) -
(3)]));
yyerrok;
@@ -3381,35 +3379,35 @@ regular_loop:
case 103:
/* Line 1806 of yacc.c */
-#line 1225 "awkgram.y"
+#line 1223 "awkgram.y"
{ (yyval) = NULL; }
break;
case 104:
/* Line 1806 of yacc.c */
-#line 1227 "awkgram.y"
+#line 1225 "awkgram.y"
{ (yyval) = NULL; }
break;
case 105:
/* Line 1806 of yacc.c */
-#line 1229 "awkgram.y"
+#line 1227 "awkgram.y"
{ (yyval) = NULL; }
break;
case 106:
/* Line 1806 of yacc.c */
-#line 1231 "awkgram.y"
+#line 1229 "awkgram.y"
{ (yyval) = NULL; }
break;
case 107:
/* Line 1806 of yacc.c */
-#line 1237 "awkgram.y"
+#line 1235 "awkgram.y"
{
if (do_lint && (yyvsp[(3) - (3)])->lasti->opcode ==
Op_match_rec)
lintwarn_ln((yyvsp[(2) - (3)])->source_line,
@@ -3421,21 +3419,21 @@ regular_loop:
case 108:
/* Line 1806 of yacc.c */
-#line 1244 "awkgram.y"
+#line 1242 "awkgram.y"
{ (yyval) = mk_boolean((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2)
- (3)])); }
break;
case 109:
/* Line 1806 of yacc.c */
-#line 1246 "awkgram.y"
+#line 1244 "awkgram.y"
{ (yyval) = mk_boolean((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2)
- (3)])); }
break;
case 110:
/* Line 1806 of yacc.c */
-#line 1248 "awkgram.y"
+#line 1246 "awkgram.y"
{
if ((yyvsp[(1) - (3)])->lasti->opcode == Op_match_rec)
warning_ln((yyvsp[(2) - (3)])->source_line,
@@ -3456,7 +3454,7 @@ regular_loop:
case 111:
/* Line 1806 of yacc.c */
-#line 1264 "awkgram.y"
+#line 1262 "awkgram.y"
{
if (do_lint_old)
warning_ln((yyvsp[(2) - (3)])->source_line,
@@ -3471,7 +3469,7 @@ regular_loop:
case 112:
/* Line 1806 of yacc.c */
-#line 1274 "awkgram.y"
+#line 1272 "awkgram.y"
{
if (do_lint && (yyvsp[(3) - (3)])->lasti->opcode ==
Op_match_rec)
lintwarn_ln((yyvsp[(2) - (3)])->source_line,
@@ -3483,35 +3481,35 @@ regular_loop:
case 113:
/* Line 1806 of yacc.c */
-#line 1281 "awkgram.y"
+#line 1279 "awkgram.y"
{ (yyval) = mk_condition((yyvsp[(1) - (5)]), (yyvsp[(2) - (5)]),
(yyvsp[(3) - (5)]), (yyvsp[(4) - (5)]), (yyvsp[(5) - (5)])); }
break;
case 114:
/* Line 1806 of yacc.c */
-#line 1283 "awkgram.y"
+#line 1281 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 115:
/* Line 1806 of yacc.c */
-#line 1288 "awkgram.y"
+#line 1286 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 116:
/* Line 1806 of yacc.c */
-#line 1290 "awkgram.y"
+#line 1288 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 117:
/* Line 1806 of yacc.c */
-#line 1292 "awkgram.y"
+#line 1290 "awkgram.y"
{
(yyvsp[(2) - (2)])->opcode = Op_assign_quotient;
(yyval) = (yyvsp[(2) - (2)]);
@@ -3521,49 +3519,49 @@ regular_loop:
case 118:
/* Line 1806 of yacc.c */
-#line 1300 "awkgram.y"
+#line 1298 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 119:
/* Line 1806 of yacc.c */
-#line 1302 "awkgram.y"
+#line 1300 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 120:
/* Line 1806 of yacc.c */
-#line 1307 "awkgram.y"
+#line 1305 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 121:
/* Line 1806 of yacc.c */
-#line 1309 "awkgram.y"
+#line 1307 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 122:
/* Line 1806 of yacc.c */
-#line 1314 "awkgram.y"
+#line 1312 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 123:
/* Line 1806 of yacc.c */
-#line 1316 "awkgram.y"
+#line 1314 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 124:
/* Line 1806 of yacc.c */
-#line 1318 "awkgram.y"
+#line 1316 "awkgram.y"
{
int count = 2;
int is_simple_var = FALSE;
@@ -3618,49 +3616,49 @@ regular_loop:
case 126:
/* Line 1806 of yacc.c */
-#line 1373 "awkgram.y"
+#line 1371 "awkgram.y"
{ (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) -
(3)])); }
break;
case 127:
/* Line 1806 of yacc.c */
-#line 1375 "awkgram.y"
+#line 1373 "awkgram.y"
{ (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) -
(3)])); }
break;
case 128:
/* Line 1806 of yacc.c */
-#line 1377 "awkgram.y"
+#line 1375 "awkgram.y"
{ (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) -
(3)])); }
break;
case 129:
/* Line 1806 of yacc.c */
-#line 1379 "awkgram.y"
+#line 1377 "awkgram.y"
{ (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) -
(3)])); }
break;
case 130:
/* Line 1806 of yacc.c */
-#line 1381 "awkgram.y"
+#line 1379 "awkgram.y"
{ (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) -
(3)])); }
break;
case 131:
/* Line 1806 of yacc.c */
-#line 1383 "awkgram.y"
+#line 1381 "awkgram.y"
{ (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) -
(3)])); }
break;
case 132:
/* Line 1806 of yacc.c */
-#line 1385 "awkgram.y"
+#line 1383 "awkgram.y"
{
/*
* In BEGINFILE/ENDFILE, allow `getline var < file'
@@ -3688,7 +3686,7 @@ regular_loop:
case 133:
/* Line 1806 of yacc.c */
-#line 1408 "awkgram.y"
+#line 1406 "awkgram.y"
{
(yyvsp[(2) - (2)])->opcode = Op_postincrement;
(yyval) = mk_assignment((yyvsp[(1) - (2)]), NULL, (yyvsp[(2) -
(2)]));
@@ -3698,7 +3696,7 @@ regular_loop:
case 134:
/* Line 1806 of yacc.c */
-#line 1413 "awkgram.y"
+#line 1411 "awkgram.y"
{
(yyvsp[(2) - (2)])->opcode = Op_postdecrement;
(yyval) = mk_assignment((yyvsp[(1) - (2)]), NULL, (yyvsp[(2) -
(2)]));
@@ -3708,7 +3706,7 @@ regular_loop:
case 135:
/* Line 1806 of yacc.c */
-#line 1418 "awkgram.y"
+#line 1416 "awkgram.y"
{
if (do_lint_old) {
warning_ln((yyvsp[(4) - (5)])->source_line,
@@ -3733,7 +3731,7 @@ regular_loop:
case 136:
/* Line 1806 of yacc.c */
-#line 1443 "awkgram.y"
+#line 1441 "awkgram.y"
{
(yyval) = mk_getline((yyvsp[(3) - (4)]), (yyvsp[(4) - (4)]),
(yyvsp[(1) - (4)]), (yyvsp[(2) - (4)])->redir_type);
bcfree((yyvsp[(2) - (4)]));
@@ -3743,49 +3741,49 @@ regular_loop:
case 137:
/* Line 1806 of yacc.c */
-#line 1449 "awkgram.y"
+#line 1447 "awkgram.y"
{ (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) -
(3)])); }
break;
case 138:
/* Line 1806 of yacc.c */
-#line 1451 "awkgram.y"
+#line 1449 "awkgram.y"
{ (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) -
(3)])); }
break;
case 139:
/* Line 1806 of yacc.c */
-#line 1453 "awkgram.y"
+#line 1451 "awkgram.y"
{ (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) -
(3)])); }
break;
case 140:
/* Line 1806 of yacc.c */
-#line 1455 "awkgram.y"
+#line 1453 "awkgram.y"
{ (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) -
(3)])); }
break;
case 141:
/* Line 1806 of yacc.c */
-#line 1457 "awkgram.y"
+#line 1455 "awkgram.y"
{ (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) -
(3)])); }
break;
case 142:
/* Line 1806 of yacc.c */
-#line 1459 "awkgram.y"
+#line 1457 "awkgram.y"
{ (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) -
(3)])); }
break;
case 143:
/* Line 1806 of yacc.c */
-#line 1464 "awkgram.y"
+#line 1462 "awkgram.y"
{
(yyval) = list_create((yyvsp[(1) - (1)]));
}
@@ -3794,7 +3792,7 @@ regular_loop:
case 144:
/* Line 1806 of yacc.c */
-#line 1468 "awkgram.y"
+#line 1466 "awkgram.y"
{
if ((yyvsp[(2) - (2)])->opcode == Op_match_rec) {
(yyvsp[(2) - (2)])->opcode = Op_nomatch;
@@ -3830,14 +3828,14 @@ regular_loop:
case 145:
/* Line 1806 of yacc.c */
-#line 1499 "awkgram.y"
+#line 1497 "awkgram.y"
{ (yyval) = (yyvsp[(2) - (3)]); }
break;
case 146:
/* Line 1806 of yacc.c */
-#line 1501 "awkgram.y"
+#line 1499 "awkgram.y"
{
(yyval) = snode((yyvsp[(3) - (4)]), (yyvsp[(1) - (4)]));
if ((yyval) == NULL)
@@ -3848,7 +3846,7 @@ regular_loop:
case 147:
/* Line 1806 of yacc.c */
-#line 1507 "awkgram.y"
+#line 1505 "awkgram.y"
{
(yyval) = snode((yyvsp[(3) - (4)]), (yyvsp[(1) - (4)]));
if ((yyval) == NULL)
@@ -3859,7 +3857,7 @@ regular_loop:
case 148:
/* Line 1806 of yacc.c */
-#line 1513 "awkgram.y"
+#line 1511 "awkgram.y"
{
static short warned1 = FALSE;
@@ -3877,7 +3875,7 @@ regular_loop:
case 151:
/* Line 1806 of yacc.c */
-#line 1528 "awkgram.y"
+#line 1526 "awkgram.y"
{
(yyvsp[(1) - (2)])->opcode = Op_preincrement;
(yyval) = mk_assignment((yyvsp[(2) - (2)]), NULL, (yyvsp[(1) -
(2)]));
@@ -3887,7 +3885,7 @@ regular_loop:
case 152:
/* Line 1806 of yacc.c */
-#line 1533 "awkgram.y"
+#line 1531 "awkgram.y"
{
(yyvsp[(1) - (2)])->opcode = Op_predecrement;
(yyval) = mk_assignment((yyvsp[(2) - (2)]), NULL, (yyvsp[(1) -
(2)]));
@@ -3897,7 +3895,7 @@ regular_loop:
case 153:
/* Line 1806 of yacc.c */
-#line 1538 "awkgram.y"
+#line 1536 "awkgram.y"
{
(yyval) = list_create((yyvsp[(1) - (1)]));
}
@@ -3906,7 +3904,7 @@ regular_loop:
case 154:
/* Line 1806 of yacc.c */
-#line 1542 "awkgram.y"
+#line 1540 "awkgram.y"
{
(yyval) = list_create((yyvsp[(1) - (1)]));
}
@@ -3915,7 +3913,7 @@ regular_loop:
case 155:
/* Line 1806 of yacc.c */
-#line 1546 "awkgram.y"
+#line 1544 "awkgram.y"
{
if ((yyvsp[(2) - (2)])->lasti->opcode == Op_push_i
&& ((yyvsp[(2) - (2)])->lasti->memory->flags &
(STRCUR|STRING)) == 0) {
@@ -3932,7 +3930,7 @@ regular_loop:
case 156:
/* Line 1806 of yacc.c */
-#line 1558 "awkgram.y"
+#line 1556 "awkgram.y"
{
/*
* was: $$ = $2
@@ -3947,7 +3945,7 @@ regular_loop:
case 157:
/* Line 1806 of yacc.c */
-#line 1571 "awkgram.y"
+#line 1569 "awkgram.y"
{
func_use((yyvsp[(1) - (1)])->lasti->func_name, FUNC_USE);
(yyval) = (yyvsp[(1) - (1)]);
@@ -3957,7 +3955,7 @@ regular_loop:
case 158:
/* Line 1806 of yacc.c */
-#line 1576 "awkgram.y"
+#line 1574 "awkgram.y"
{
/* indirect function call */
INSTRUCTION *f, *t;
@@ -3995,7 +3993,7 @@ regular_loop:
case 159:
/* Line 1806 of yacc.c */
-#line 1612 "awkgram.y"
+#line 1610 "awkgram.y"
{
param_sanity((yyvsp[(3) - (4)]));
(yyvsp[(1) - (4)])->opcode = Op_func_call;
@@ -4014,42 +4012,42 @@ regular_loop:
case 160:
/* Line 1806 of yacc.c */
-#line 1629 "awkgram.y"
+#line 1627 "awkgram.y"
{ (yyval) = NULL; }
break;
case 161:
/* Line 1806 of yacc.c */
-#line 1631 "awkgram.y"
+#line 1629 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 162:
/* Line 1806 of yacc.c */
-#line 1636 "awkgram.y"
+#line 1634 "awkgram.y"
{ (yyval) = NULL; }
break;
case 163:
/* Line 1806 of yacc.c */
-#line 1638 "awkgram.y"
+#line 1636 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (2)]); }
break;
case 164:
/* Line 1806 of yacc.c */
-#line 1643 "awkgram.y"
+#line 1641 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 165:
/* Line 1806 of yacc.c */
-#line 1645 "awkgram.y"
+#line 1643 "awkgram.y"
{
(yyval) = list_merge((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)]));
}
@@ -4058,7 +4056,7 @@ regular_loop:
case 166:
/* Line 1806 of yacc.c */
-#line 1652 "awkgram.y"
+#line 1650 "awkgram.y"
{
INSTRUCTION *ip = (yyvsp[(1) - (1)])->lasti;
int count = ip->sub_count; /* # of SUBSEP-seperated
expressions */
@@ -4077,7 +4075,7 @@ regular_loop:
case 167:
/* Line 1806 of yacc.c */
-#line 1669 "awkgram.y"
+#line 1667 "awkgram.y"
{
INSTRUCTION *t = (yyvsp[(2) - (3)]);
if ((yyvsp[(2) - (3)]) == NULL) {
@@ -4096,14 +4094,14 @@ regular_loop:
case 168:
/* Line 1806 of yacc.c */
-#line 1686 "awkgram.y"
+#line 1684 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 169:
/* Line 1806 of yacc.c */
-#line 1688 "awkgram.y"
+#line 1686 "awkgram.y"
{
(yyval) = list_merge((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)]));
}
@@ -4112,14 +4110,14 @@ regular_loop:
case 170:
/* Line 1806 of yacc.c */
-#line 1695 "awkgram.y"
+#line 1693 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (2)]); }
break;
case 171:
/* Line 1806 of yacc.c */
-#line 1700 "awkgram.y"
+#line 1698 "awkgram.y"
{
char *var_name = (yyvsp[(1) - (1)])->lextok;
@@ -4132,7 +4130,7 @@ regular_loop:
case 172:
/* Line 1806 of yacc.c */
-#line 1708 "awkgram.y"
+#line 1706 "awkgram.y"
{
NODE *n;
@@ -4148,7 +4146,7 @@ regular_loop:
case 173:
/* Line 1806 of yacc.c */
-#line 1722 "awkgram.y"
+#line 1720 "awkgram.y"
{
INSTRUCTION *ip = (yyvsp[(1) - (1)])->nexti;
if (ip->opcode == Op_push
@@ -4156,7 +4154,6 @@ regular_loop:
&& ip->memory->var_update
) {
(yyval) = list_prepend((yyvsp[(1) - (1)]),
instruction(Op_var_update));
- (yyval)->nexti->memory = ip->memory;
(yyval)->nexti->update_var = ip->memory->var_update;
} else
(yyval) = (yyvsp[(1) - (1)]);
@@ -4166,7 +4163,7 @@ regular_loop:
case 174:
/* Line 1806 of yacc.c */
-#line 1735 "awkgram.y"
+#line 1732 "awkgram.y"
{
(yyval) = list_append((yyvsp[(2) - (3)]), (yyvsp[(1) - (3)]));
if ((yyvsp[(3) - (3)]) != NULL)
@@ -4177,7 +4174,7 @@ regular_loop:
case 175:
/* Line 1806 of yacc.c */
-#line 1744 "awkgram.y"
+#line 1741 "awkgram.y"
{
(yyvsp[(1) - (1)])->opcode = Op_postincrement;
}
@@ -4186,7 +4183,7 @@ regular_loop:
case 176:
/* Line 1806 of yacc.c */
-#line 1748 "awkgram.y"
+#line 1745 "awkgram.y"
{
(yyvsp[(1) - (1)])->opcode = Op_postdecrement;
}
@@ -4195,49 +4192,49 @@ regular_loop:
case 177:
/* Line 1806 of yacc.c */
-#line 1751 "awkgram.y"
+#line 1748 "awkgram.y"
{ (yyval) = NULL; }
break;
case 179:
/* Line 1806 of yacc.c */
-#line 1759 "awkgram.y"
+#line 1756 "awkgram.y"
{ yyerrok; }
break;
case 180:
/* Line 1806 of yacc.c */
-#line 1763 "awkgram.y"
+#line 1760 "awkgram.y"
{ yyerrok; }
break;
case 183:
/* Line 1806 of yacc.c */
-#line 1772 "awkgram.y"
+#line 1769 "awkgram.y"
{ yyerrok; }
break;
case 184:
/* Line 1806 of yacc.c */
-#line 1776 "awkgram.y"
+#line 1773 "awkgram.y"
{ (yyval) = (yyvsp[(1) - (1)]); yyerrok; }
break;
case 185:
/* Line 1806 of yacc.c */
-#line 1780 "awkgram.y"
+#line 1777 "awkgram.y"
{ yyerrok; }
break;
/* Line 1806 of yacc.c */
-#line 4253 "awkgram.c"
+#line 4250 "awkgram.c"
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@@ -4468,7 +4465,7 @@ yyreturn:
/* Line 2067 of yacc.c */
-#line 1782 "awkgram.y"
+#line 1779 "awkgram.y"
struct token {
@@ -6344,14 +6341,13 @@ snode(INSTRUCTION *subn, INSTRUCTION *r)
/* add after_assign code */
if (ip->opcode == Op_push_lhs && ip->memory->type ==
Node_var && ip->memory->var_assign) {
(void) list_append(subn,
instruction(Op_var_assign));
- subn->lasti->memory = ip->memory;
+ subn->lasti->assign_ctxt = Op_sub_builtin;
subn->lasti->assign_var =
ip->memory->var_assign;
- r->sub_flags |= AFTER_ASSIGN;
} else if (ip->opcode == Op_field_spec_lhs) {
(void) list_append(subn,
instruction(Op_field_assign));
+ subn->lasti->assign_ctxt = Op_sub_builtin;
subn->lasti->field_assign = (Func_ptr) 0;
ip->target_assign = subn->lasti;
- r->sub_flags |= AFTER_ASSIGN;
}
return subn;
@@ -7816,7 +7812,6 @@ mk_assignment(INSTRUCTION *lhs, INSTRUCTION *rhs,
INSTRUCTION *op)
* for a special variable.
*/
(void) list_append(ip, instruction(Op_var_assign));
- ip->lasti->memory = tp->memory;
ip->lasti->assign_var = tp->memory->var_assign;
} else if (tp->opcode == Op_field_spec_lhs) {
(void) list_append(ip, instruction(Op_field_assign));
@@ -8013,10 +8008,11 @@ mk_getline(INSTRUCTION *op, INSTRUCTION *var,
INSTRUCTION *redir, int redirtype)
&& tp->memory->var_assign
) {
asgn = instruction(Op_var_assign);
- asgn->memory = tp->memory;
+ asgn->assign_ctxt = op->opcode;
asgn->assign_var = tp->memory->var_assign;
} else if (tp->opcode == Op_field_spec_lhs) {
asgn = instruction(Op_field_assign);
+ asgn->assign_ctxt = op->opcode;
asgn->field_assign = (Func_ptr) 0; /* determined at
run time */
tp->target_assign = asgn;
}
diff --git a/awkgram.y b/awkgram.y
index 3ef6382..fb917c2 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -750,7 +750,6 @@ regular_loop:
/* add update_FOO instruction if necessary */
if ($4->array_var->type == Node_var &&
$4->array_var->var_update) {
(void) list_append(ip,
instruction(Op_var_update));
- ip->lasti->memory = $4->array_var;
ip->lasti->update_var =
$4->array_var->var_update;
}
(void) list_append(ip, $4);
@@ -758,7 +757,6 @@ regular_loop:
/* add set_FOO instruction if necessary */
if ($4->array_var->type == Node_var &&
$4->array_var->var_assign) {
(void) list_append(ip,
instruction(Op_var_assign));
- ip->lasti->memory = $4->array_var;
ip->lasti->assign_var =
$4->array_var->var_assign;
}
@@ -1726,7 +1724,6 @@ variable
&& ip->memory->var_update
) {
$$ = list_prepend($1, instruction(Op_var_update));
- $$->nexti->memory = ip->memory;
$$->nexti->update_var = ip->memory->var_update;
} else
$$ = $1;
@@ -3654,14 +3651,13 @@ snode(INSTRUCTION *subn, INSTRUCTION *r)
/* add after_assign code */
if (ip->opcode == Op_push_lhs && ip->memory->type ==
Node_var && ip->memory->var_assign) {
(void) list_append(subn,
instruction(Op_var_assign));
- subn->lasti->memory = ip->memory;
+ subn->lasti->assign_ctxt = Op_sub_builtin;
subn->lasti->assign_var =
ip->memory->var_assign;
- r->sub_flags |= AFTER_ASSIGN;
} else if (ip->opcode == Op_field_spec_lhs) {
(void) list_append(subn,
instruction(Op_field_assign));
+ subn->lasti->assign_ctxt = Op_sub_builtin;
subn->lasti->field_assign = (Func_ptr) 0;
ip->target_assign = subn->lasti;
- r->sub_flags |= AFTER_ASSIGN;
}
return subn;
@@ -5126,7 +5122,6 @@ mk_assignment(INSTRUCTION *lhs, INSTRUCTION *rhs,
INSTRUCTION *op)
* for a special variable.
*/
(void) list_append(ip, instruction(Op_var_assign));
- ip->lasti->memory = tp->memory;
ip->lasti->assign_var = tp->memory->var_assign;
} else if (tp->opcode == Op_field_spec_lhs) {
(void) list_append(ip, instruction(Op_field_assign));
@@ -5323,10 +5318,11 @@ mk_getline(INSTRUCTION *op, INSTRUCTION *var,
INSTRUCTION *redir, int redirtype)
&& tp->memory->var_assign
) {
asgn = instruction(Op_var_assign);
- asgn->memory = tp->memory;
+ asgn->assign_ctxt = op->opcode;
asgn->assign_var = tp->memory->var_assign;
} else if (tp->opcode == Op_field_spec_lhs) {
asgn = instruction(Op_field_assign);
+ asgn->assign_ctxt = op->opcode;
asgn->field_assign = (Func_ptr) 0; /* determined at
run time */
tp->target_assign = asgn;
}
diff --git a/builtin.c b/builtin.c
index 5b75979..8685d29 100644
--- a/builtin.c
+++ b/builtin.c
@@ -2412,7 +2412,7 @@ do_match(int nargs)
*/
NODE *
-do_sub(int nargs, unsigned int flags, int *num_matches)
+do_sub(int nargs, unsigned int flags)
{
char *scan;
char *bp, *cp;
@@ -2680,7 +2680,6 @@ set_how_many:
done:
DEREF(s);
- *num_matches = matches;
if ((matches == 0 || (flags & LITERAL) != 0) && buf != NULL)
efree(buf);
diff --git a/debug.c b/debug.c
index 404042c..4cda95c 100644
--- a/debug.c
+++ b/debug.c
@@ -39,6 +39,7 @@ extern long fcall_count;
extern FILE *output_fp;
extern IOBUF *curfile;
extern const char *command_file;
+extern const char *get_spec_varname(Func_ptr fptr);
extern int r_interpret(INSTRUCTION *);
extern int zzparse(void);
#define read_command() (void) zzparse()
@@ -3736,20 +3737,19 @@ print_instruction(INSTRUCTION *pc, Func_print
print_func, FILE *fp, int in_dump)
switch (pc->opcode) {
case Op_var_update:
- print_func(fp, "[update_%s]\n", pc->memory->vname);
+ print_func(fp, "[update_%s()]\n",
get_spec_varname(pc->update_var));
break;
case Op_var_assign:
- if (pc->assign_var)
- print_func(fp, "[set_%s()]", pc->memory->vname);
+ print_func(fp, "[set_%s()]", get_spec_varname(pc->assign_var));
+ if (pc->assign_ctxt != 0)
+ print_func(fp, " [assign_ctxt = %s]",
opcode2str(pc->assign_ctxt));
print_func(fp, "\n");
break;
case Op_field_assign:
- if (pc->field_assign)
- print_func(fp, "[%s]", pc->field_assign == reset_record
?
+ print_func(fp, "[%s]\n", pc->field_assign == reset_record ?
"reset_record()" :
"invalidate_field0()");
- print_func(fp, "\n");
break;
case Op_field_spec_lhs:
@@ -3843,9 +3843,8 @@ print_instruction(INSTRUCTION *pc, Func_print print_func,
FILE *fp, int in_dump)
{
const char *fname = "sub";
static const struct flagtab values[] = {
- { GSUB, "GSUB" },
+ { GSUB, "GSUB" },
{ GENSUB, "GENSUB" },
- { AFTER_ASSIGN, "AFTER_ASSIGN" },
{ LITERAL, "LITERAL" },
{ 0, NULL }
};
diff --git a/eval.c b/eval.c
index bdbd04b..bd3e027 100644
--- a/eval.c
+++ b/eval.c
@@ -2115,12 +2115,27 @@ post:
break;
case Op_var_assign:
- if (pc->assign_var)
- pc->assign_var();
- break;
-
case Op_field_assign:
- if (pc->field_assign)
+ if (pc->assign_ctxt == Op_sub_builtin
+ && TOP()->numbr == 0.0 /* top of stack has a
number == 0 */
+ ) {
+ /* There wasn't any substitutions. If the
target is a FIELD,
+ * this means no field re-splitting or $0
reconstruction.
+ * Skip the set_FOO routine if the target is a
special variable.
+ */
+
+ break;
+ } else if (pc->assign_ctxt == Op_K_getline
+ && TOP()->numbr <= 0.0 /* top of stack has a
number <= 0 */
+ ) {
+ /* getline returned EOF or error */
+
+ break;
+ }
+
+ if (pc->opcode == Op_var_assign)
+ pc->assign_var();
+ else
pc->field_assign();
break;
@@ -2260,31 +2275,9 @@ arrayfor:
PUSH(r);
break;
- case Op_sub_builtin:
- {
- /* sub, gsub and gensub */
-
- int matches = 0;
-
- r = do_sub(pc->expr_count, pc->sub_flags, & matches);
+ case Op_sub_builtin: /* sub, gsub and gensub */
+ r = do_sub(pc->expr_count, pc->sub_flags);
PUSH(r);
-
- if (matches == 0 && (pc->sub_flags & AFTER_ASSIGN) !=
0) {
-
- /* For sub and gsub, must not execute
after_assign code;
- * If the target is a FIELD, this means no
field re-splitting or
- * $0 reconstruction. For a special variable as
target,
- * set_XX routine is not called.
- */
-
- ni = pc->nexti;
- assert(ni->opcode == Op_field_assign ||
ni->opcode == Op_var_assign);
- if (ni->opcode == Op_field_assign)
- ni->field_assign = (Func_ptr) 0;
- else
- ni->assign_var = (Func_ptr) 0;
- }
- }
break;
case Op_K_print:
@@ -2458,6 +2451,7 @@ func_call:
JUMPTO((pc +
1)->target_beginfile);
}
} while (r == NULL); /* EOF */
+
PUSH(r);
break;
diff --git a/main.c b/main.c
index 120d9ff..657de32 100644
--- a/main.c
+++ b/main.c
@@ -1127,6 +1127,26 @@ is_std_var(const char *var)
return FALSE;
}
+
+/* get_spec_varname --- return the name of a special variable
+ with the given assign or update routine.
+*/
+
+const char *
+get_spec_varname(Func_ptr fptr)
+{
+ const struct varinit *vp;
+
+ if (! fptr)
+ return NULL;
+ for (vp = varinit; vp->name != NULL; vp++) {
+ if (vp->assign == fptr || vp->update == fptr)
+ return vp->name;
+ }
+ return NULL;
+}
+
+
/* arg_assign --- process a command-line assignment */
int
diff --git a/test/ChangeLog b/test/ChangeLog
index 60c4f52..e4ad2f3 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,9 @@
+2011-07-26 Arnold D. Robbins <address@hidden>
+
+ * Makefile.am (getline4, gsubtst8): New tests.
+ * getline4.awk, getline4.in, getline4.ok: New files.
+ * gsubtst8.awk, gsubtst8.in, gsubtst8.ok: New files.
+
2011-07-15 Arnold D. Robbins <address@hidden>
* Makefile.am (gsubtst7): New test.
diff --git a/test/Makefile.am b/test/Makefile.am
index 12f64a6..82e0834 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -283,6 +283,9 @@ EXTRA_DIST = \
getline2.ok \
getline3.awk \
getline3.ok \
+ getline4.awk \
+ getline4.in \
+ getline4.ok \
getlnbuf.awk \
getlnbuf.in \
getlnbuf.ok \
@@ -321,6 +324,9 @@ EXTRA_DIST = \
gsubtst7.awk \
gsubtst7.in \
gsubtst7.ok \
+ gsubtst8.awk \
+ gsubtst8.in \
+ gsubtst8.ok \
gtlnbufv.awk \
hex.awk \
hex.ok \
@@ -769,9 +775,10 @@ BASIC_TESTS = \
dfastress dynlj eofsplit exitval1 exitval2 fcall_exit fcall_exit2 \
fldchg fldchgnf fnamedat fnarray fnarray2 fnaryscl fnasgnm fnmisc \
fordel forref forsimp fsbs fsrs fsspcoln fstabplus funsemnl funsmnam \
- funstack getline getline2 getline3 getlnbuf getnr2tb getnr2tm \
+ funstack getline getline2 getline3 getline4 \
+ getlnbuf getnr2tb getnr2tm \
gsubasgn gsubtest gsubtst2 gsubtst3 gsubtst4 gsubtst5 gsubtst6 \
- gsubtst7 \
+ gsubtst7 gsubtst8 \
hex hsprint inputred intest intprec iobug1 leaddig leadnl litoct \
longsub longwrds manglprm math membug1 messages minusstr mmap8k \
mtchi18n nasty nasty2 negexp negrange nested nfldstr nfneg \
diff --git a/test/Makefile.in b/test/Makefile.in
index eee32eb..fab7dd3 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -468,6 +468,9 @@ EXTRA_DIST = \
getline2.ok \
getline3.awk \
getline3.ok \
+ getline4.awk \
+ getline4.in \
+ getline4.ok \
getlnbuf.awk \
getlnbuf.in \
getlnbuf.ok \
@@ -506,6 +509,9 @@ EXTRA_DIST = \
gsubtst7.awk \
gsubtst7.in \
gsubtst7.ok \
+ gsubtst8.awk \
+ gsubtst8.in \
+ gsubtst8.ok \
gtlnbufv.awk \
hex.awk \
hex.ok \
@@ -954,9 +960,10 @@ BASIC_TESTS = \
dfastress dynlj eofsplit exitval1 exitval2 fcall_exit fcall_exit2 \
fldchg fldchgnf fnamedat fnarray fnarray2 fnaryscl fnasgnm fnmisc \
fordel forref forsimp fsbs fsrs fsspcoln fstabplus funsemnl funsmnam \
- funstack getline getline2 getline3 getlnbuf getnr2tb getnr2tm \
+ funstack getline getline2 getline3 getline4 \
+ getlnbuf getnr2tb getnr2tm \
gsubasgn gsubtest gsubtst2 gsubtst3 gsubtst4 gsubtst5 gsubtst6 \
- gsubtst7 \
+ gsubtst7 gsubtst8 \
hex hsprint inputred intest intprec iobug1 leaddig leadnl litoct \
longsub longwrds manglprm math membug1 messages minusstr mmap8k \
mtchi18n nasty nasty2 negexp negrange nested nfldstr nfneg \
@@ -2046,6 +2053,11 @@ getline3:
@AWKPATH=$(srcdir) $(AWK) -f address@hidden >_$@ 2>&1 || echo EXIT
CODE: $$? >>_$@
@-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+getline4:
+ @echo getline4
+ @AWKPATH=$(srcdir) $(AWK) -f address@hidden < $(srcdir)/address@hidden
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
getnr2tb:
@echo getnr2tb
@AWKPATH=$(srcdir) $(AWK) -f address@hidden < $(srcdir)/address@hidden
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@@ -2086,6 +2098,11 @@ gsubtst7:
@AWKPATH=$(srcdir) $(AWK) -f address@hidden < $(srcdir)/address@hidden
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+gsubtst8:
+ @echo gsubtst8
+ @AWKPATH=$(srcdir) $(AWK) -f address@hidden < $(srcdir)/address@hidden
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
hex:
@echo hex
@AWKPATH=$(srcdir) $(AWK) -f address@hidden >_$@ 2>&1 || echo EXIT
CODE: $$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 9f36403..d11cd6f 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -315,6 +315,11 @@ getline3:
@AWKPATH=$(srcdir) $(AWK) -f address@hidden >_$@ 2>&1 || echo EXIT
CODE: $$? >>_$@
@-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+getline4:
+ @echo getline4
+ @AWKPATH=$(srcdir) $(AWK) -f address@hidden < $(srcdir)/address@hidden
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
getnr2tb:
@echo getnr2tb
@AWKPATH=$(srcdir) $(AWK) -f address@hidden < $(srcdir)/address@hidden
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@@ -355,6 +360,11 @@ gsubtst7:
@AWKPATH=$(srcdir) $(AWK) -f address@hidden < $(srcdir)/address@hidden
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+gsubtst8:
+ @echo gsubtst8
+ @AWKPATH=$(srcdir) $(AWK) -f address@hidden < $(srcdir)/address@hidden
>_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) $(srcdir)/address@hidden _$@ && rm -f _$@
+
hex:
@echo hex
@AWKPATH=$(srcdir) $(AWK) -f address@hidden >_$@ 2>&1 || echo EXIT
CODE: $$? >>_$@
diff --git a/test/getline4.awk b/test/getline4.awk
new file mode 100644
index 0000000..275faaa
--- /dev/null
+++ b/test/getline4.awk
@@ -0,0 +1 @@
+END { getline $2; print}
diff --git a/test/getline4.in b/test/getline4.in
new file mode 100644
index 0000000..42771a3
--- /dev/null
+++ b/test/getline4.in
@@ -0,0 +1 @@
+ aaa bbb
diff --git a/test/getline4.ok b/test/getline4.ok
new file mode 100644
index 0000000..42771a3
--- /dev/null
+++ b/test/getline4.ok
@@ -0,0 +1 @@
+ aaa bbb
diff --git a/test/gsubtst8.awk b/test/gsubtst8.awk
new file mode 100644
index 0000000..818b0ea
--- /dev/null
+++ b/test/gsubtst8.awk
@@ -0,0 +1,5 @@
+{
+ OFS = " " $2 " "
+ gsub("foo", "_", OFS)
+ print $1, $2
+}
diff --git a/test/gsubtst8.in b/test/gsubtst8.in
new file mode 100644
index 0000000..f2b45c7
--- /dev/null
+++ b/test/gsubtst8.in
@@ -0,0 +1,2 @@
+a bar b
+c foo d
diff --git a/test/gsubtst8.ok b/test/gsubtst8.ok
new file mode 100644
index 0000000..d3b28cc
--- /dev/null
+++ b/test/gsubtst8.ok
@@ -0,0 +1,2 @@
+a bar bar
+c _ foo
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 16 +++
FUTURES | 2 +
awk.h | 10 +-
awkgram.c | 298 ++++++++++++++++++++++++++---------------------------
awkgram.y | 12 +--
builtin.c | 3 +-
debug.c | 15 ++--
eval.c | 52 ++++-----
main.c | 20 ++++
test/ChangeLog | 6 +
test/Makefile.am | 11 ++-
test/Makefile.in | 21 ++++-
test/Maketests | 10 ++
test/getline4.awk | 1 +
test/getline4.in | 1 +
test/getline4.ok | 1 +
test/gsubtst8.awk | 5 +
test/gsubtst8.in | 2 +
test/gsubtst8.ok | 2 +
19 files changed, 281 insertions(+), 207 deletions(-)
create mode 100644 test/getline4.awk
create mode 100644 test/getline4.in
create mode 100644 test/getline4.ok
create mode 100644 test/gsubtst8.awk
create mode 100644 test/gsubtst8.in
create mode 100644 test/gsubtst8.ok
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gawk-diffs] [SCM] gawk branch, gawk-4.0-stable, updated. 452f4efefd5511bc7dbe95b0167b10b403cdcf45,
Arnold Robbins <=