diff options
-rw-r--r-- | ChangeLog | 22 | ||||
-rw-r--r-- | awk.h | 6 | ||||
-rw-r--r-- | awkgram.c | 865 | ||||
-rw-r--r-- | awkgram.y | 147 | ||||
-rw-r--r-- | main.c | 3 | ||||
-rw-r--r-- | profile.c | 190 |
6 files changed, 659 insertions, 574 deletions
@@ -1,3 +1,25 @@ +2014-12-02 Stephen Davies <sdavies@sdc.com.au> + + Improve comment handling in pretty printing. + Create a linked-list of comments and merge them in during + pretty-printing instead of into the instruction list at + parse time. + + * awk.h (comment_type, comment_text): New defines for NODE, + INSTRUCTION. + * awkgram.y (append_comment): New function. + (program_comment, function_comment): Removed. + (first_comment, last_comment): New variables. + (get_comment): Take a flag for newline; rework storage. Adjust calls. + (split_comment): Store comments in list. + (first_comment, last_comment, current_comment_type): New variables. + (dump_funcs): Set current_comment_type. + * main.c (main): Call print_extra_comments. + * profile.c (end_line): New function. + (print_extra_comments): New function. + (lind): New variable. + (pprint): Change how comments are handled. + 2014-11-26 Arnold D. Robbins <arnold@skeeve.com> * builtin.c (do_sub): Improve wording of gensub warnings. @@ -530,6 +530,9 @@ typedef struct exp_node { #define adepth sub.nodep.l.ll #define alevel sub.nodep.x.xl +/* Op_comment */ +#define comment_type sub.val.idx + /* --------------------------------lint warning types----------------------------*/ typedef enum lintvals { LINT_illegal, @@ -794,6 +797,9 @@ typedef struct exp_instruction { /* Op_arrayfor_incr */ #define array_var x.xn +/* Op_comment */ +#define comment_text x.xn + /* Op_line_range */ #define triggered x.xl @@ -98,6 +98,8 @@ static int load_library(INSTRUCTION *file); static void next_sourcefile(void); static char *tokexpand(void); static bool is_deferred_variable(const char *name); +static void split_comment(void); +static void append_comment(INSTRUCTION *ip); #define instruction(t) bcalloc(t, 1, 0) @@ -127,7 +129,6 @@ static void check_funcs(void); static ssize_t read_one_line(int fd, void *buffer, size_t count); static int one_line_close(int fd); -static void split_comment(void); static bool want_source = false; static bool want_regexp = false; /* lexical scanning kludge */ @@ -188,8 +189,6 @@ static INSTRUCTION *ip_endfile; static INSTRUCTION *ip_beginfile; static INSTRUCTION *comment = NULL; -static INSTRUCTION *program_comment = NULL; -static INSTRUCTION *function_comment = NULL; static bool func_first = true; @@ -200,9 +199,15 @@ static inline INSTRUCTION *list_merge(INSTRUCTION *l1, INSTRUCTION *l2); extern double fmod(double x, double y); +/* first and last pointers to comment list */ +INSTRUCTION *first_comment = NULL; +INSTRUCTION *last_comment = NULL; +/* comment type (program=0, function=1) */ +int current_comment_type = 0; + #define YYSTYPE INSTRUCTION * -#line 206 "awkgram.c" /* yacc.c:339 */ +#line 211 "awkgram.c" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus @@ -356,7 +361,7 @@ int yyparse (void); /* Copy the second part of user declarations. */ -#line 360 "awkgram.c" /* yacc.c:358 */ +#line 365 "awkgram.c" /* yacc.c:358 */ #ifdef short # undef short @@ -658,25 +663,25 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 205, 205, 207, 212, 213, 219, 231, 235, 246, - 252, 257, 265, 273, 275, 280, 288, 290, 296, 304, - 314, 340, 353, 366, 373, 383, 395, 397, 399, 405, - 410, 411, 415, 450, 449, 483, 485, 490, 496, 524, - 529, 530, 534, 536, 538, 545, 635, 677, 719, 832, - 839, 846, 856, 865, 874, 883, 894, 910, 909, 933, - 945, 945, 1043, 1043, 1076, 1106, 1112, 1113, 1119, 1120, - 1127, 1132, 1144, 1158, 1160, 1168, 1173, 1175, 1183, 1185, - 1194, 1195, 1203, 1208, 1208, 1219, 1223, 1231, 1232, 1235, - 1237, 1242, 1243, 1252, 1253, 1258, 1263, 1269, 1271, 1273, - 1280, 1281, 1287, 1288, 1293, 1295, 1300, 1302, 1310, 1315, - 1324, 1331, 1333, 1335, 1351, 1361, 1368, 1370, 1375, 1377, - 1379, 1387, 1389, 1394, 1396, 1401, 1403, 1405, 1455, 1457, - 1459, 1461, 1463, 1465, 1467, 1469, 1483, 1488, 1493, 1518, - 1524, 1526, 1528, 1530, 1532, 1534, 1539, 1543, 1575, 1577, - 1583, 1589, 1602, 1603, 1604, 1609, 1614, 1618, 1622, 1637, - 1650, 1655, 1691, 1709, 1710, 1716, 1717, 1722, 1724, 1731, - 1748, 1765, 1767, 1774, 1779, 1787, 1797, 1809, 1818, 1822, - 1826, 1830, 1834, 1838, 1841, 1843, 1847, 1851, 1855 + 0, 210, 210, 212, 217, 218, 224, 236, 240, 251, + 257, 262, 270, 278, 280, 285, 293, 295, 301, 305, + 311, 337, 350, 363, 370, 380, 398, 400, 402, 408, + 413, 414, 418, 449, 448, 482, 484, 489, 492, 506, + 511, 512, 516, 518, 520, 527, 617, 659, 701, 814, + 821, 828, 838, 847, 856, 865, 876, 892, 891, 915, + 927, 927, 1025, 1025, 1058, 1088, 1094, 1095, 1101, 1102, + 1109, 1114, 1126, 1140, 1142, 1150, 1155, 1157, 1165, 1167, + 1176, 1177, 1185, 1190, 1190, 1201, 1205, 1213, 1214, 1217, + 1219, 1224, 1225, 1234, 1235, 1240, 1245, 1251, 1253, 1255, + 1262, 1263, 1269, 1270, 1275, 1277, 1282, 1284, 1292, 1297, + 1306, 1313, 1315, 1317, 1333, 1343, 1350, 1352, 1357, 1359, + 1361, 1369, 1371, 1376, 1378, 1383, 1385, 1387, 1437, 1439, + 1441, 1443, 1445, 1447, 1449, 1451, 1465, 1470, 1475, 1500, + 1506, 1508, 1510, 1512, 1514, 1516, 1521, 1525, 1557, 1559, + 1565, 1571, 1584, 1585, 1586, 1591, 1596, 1600, 1604, 1619, + 1632, 1637, 1673, 1691, 1692, 1698, 1699, 1704, 1706, 1713, + 1730, 1747, 1749, 1756, 1761, 1769, 1779, 1791, 1800, 1804, + 1808, 1812, 1816, 1820, 1823, 1825, 1829, 1833, 1837 }; #endif @@ -1849,26 +1854,26 @@ yyreduce: switch (yyn) { case 3: -#line 208 "awkgram.y" /* yacc.c:1646 */ +#line 213 "awkgram.y" /* yacc.c:1646 */ { rule = 0; yyerrok; } -#line 1858 "awkgram.c" /* yacc.c:1646 */ +#line 1863 "awkgram.c" /* yacc.c:1646 */ break; case 5: -#line 214 "awkgram.y" /* yacc.c:1646 */ +#line 219 "awkgram.y" /* yacc.c:1646 */ { next_sourcefile(); if (sourcefile == srcfiles) process_deferred(); } -#line 1868 "awkgram.c" /* yacc.c:1646 */ +#line 1873 "awkgram.c" /* yacc.c:1646 */ break; case 6: -#line 220 "awkgram.y" /* yacc.c:1646 */ +#line 225 "awkgram.y" /* yacc.c:1646 */ { rule = 0; /* @@ -1877,19 +1882,19 @@ yyreduce: */ /* yyerrok; */ } -#line 1881 "awkgram.c" /* yacc.c:1646 */ +#line 1886 "awkgram.c" /* yacc.c:1646 */ break; case 7: -#line 232 "awkgram.y" /* yacc.c:1646 */ +#line 237 "awkgram.y" /* yacc.c:1646 */ { (void) append_rule((yyvsp[-1]), (yyvsp[0])); } -#line 1889 "awkgram.c" /* yacc.c:1646 */ +#line 1894 "awkgram.c" /* yacc.c:1646 */ break; case 8: -#line 236 "awkgram.y" /* yacc.c:1646 */ +#line 241 "awkgram.y" /* yacc.c:1646 */ { if (rule != Rule) { msg(_("%s blocks must have an action part"), ruletab[rule]); @@ -1900,39 +1905,39 @@ yyreduce: } else /* pattern rule with non-empty pattern */ (void) append_rule((yyvsp[-1]), NULL); } -#line 1904 "awkgram.c" /* yacc.c:1646 */ +#line 1909 "awkgram.c" /* yacc.c:1646 */ break; case 9: -#line 247 "awkgram.y" /* yacc.c:1646 */ +#line 252 "awkgram.y" /* yacc.c:1646 */ { in_function = NULL; (void) mk_function((yyvsp[-1]), (yyvsp[0])); yyerrok; } -#line 1914 "awkgram.c" /* yacc.c:1646 */ +#line 1919 "awkgram.c" /* yacc.c:1646 */ break; case 10: -#line 253 "awkgram.y" /* yacc.c:1646 */ +#line 258 "awkgram.y" /* yacc.c:1646 */ { want_source = false; yyerrok; } -#line 1923 "awkgram.c" /* yacc.c:1646 */ +#line 1928 "awkgram.c" /* yacc.c:1646 */ break; case 11: -#line 258 "awkgram.y" /* yacc.c:1646 */ +#line 263 "awkgram.y" /* yacc.c:1646 */ { want_source = false; yyerrok; } -#line 1932 "awkgram.c" /* yacc.c:1646 */ +#line 1937 "awkgram.c" /* yacc.c:1646 */ break; case 12: -#line 266 "awkgram.y" /* yacc.c:1646 */ +#line 271 "awkgram.y" /* yacc.c:1646 */ { if (include_source((yyvsp[0])) < 0) YYABORT; @@ -1940,23 +1945,23 @@ yyreduce: bcfree((yyvsp[0])); (yyval) = NULL; } -#line 1944 "awkgram.c" /* yacc.c:1646 */ +#line 1949 "awkgram.c" /* yacc.c:1646 */ break; case 13: -#line 274 "awkgram.y" /* yacc.c:1646 */ +#line 279 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1950 "awkgram.c" /* yacc.c:1646 */ +#line 1955 "awkgram.c" /* yacc.c:1646 */ break; case 14: -#line 276 "awkgram.y" /* yacc.c:1646 */ +#line 281 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1956 "awkgram.c" /* yacc.c:1646 */ +#line 1961 "awkgram.c" /* yacc.c:1646 */ break; case 15: -#line 281 "awkgram.y" /* yacc.c:1646 */ +#line 286 "awkgram.y" /* yacc.c:1646 */ { if (load_library((yyvsp[0])) < 0) YYABORT; @@ -1964,49 +1969,41 @@ yyreduce: bcfree((yyvsp[0])); (yyval) = NULL; } -#line 1968 "awkgram.c" /* yacc.c:1646 */ +#line 1973 "awkgram.c" /* yacc.c:1646 */ break; case 16: -#line 289 "awkgram.y" /* yacc.c:1646 */ +#line 294 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1974 "awkgram.c" /* yacc.c:1646 */ +#line 1979 "awkgram.c" /* yacc.c:1646 */ break; case 17: -#line 291 "awkgram.y" /* yacc.c:1646 */ +#line 296 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1980 "awkgram.c" /* yacc.c:1646 */ +#line 1985 "awkgram.c" /* yacc.c:1646 */ break; case 18: -#line 296 "awkgram.y" /* yacc.c:1646 */ +#line 301 "awkgram.y" /* yacc.c:1646 */ { rule = Rule; - if (comment != NULL) { - (yyval) = list_create(comment); - comment = NULL; - } else - (yyval) = NULL; + (yyval) = NULL; } -#line 1993 "awkgram.c" /* yacc.c:1646 */ +#line 1994 "awkgram.c" /* yacc.c:1646 */ break; case 19: -#line 305 "awkgram.y" /* yacc.c:1646 */ +#line 306 "awkgram.y" /* yacc.c:1646 */ { rule = Rule; - if (comment != NULL) { - (yyval) = list_prepend((yyvsp[0]), comment); - comment = NULL; - } else - (yyval) = (yyvsp[0]); + (yyval) = (yyvsp[0]); } -#line 2006 "awkgram.c" /* yacc.c:1646 */ +#line 2003 "awkgram.c" /* yacc.c:1646 */ break; case 20: -#line 315 "awkgram.y" /* yacc.c:1646 */ +#line 312 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *tp; @@ -2032,11 +2029,11 @@ yyreduce: (yyval) = list_append(list_merge((yyvsp[-3]), (yyvsp[0])), tp); rule = Rule; } -#line 2036 "awkgram.c" /* yacc.c:1646 */ +#line 2033 "awkgram.c" /* yacc.c:1646 */ break; case 21: -#line 341 "awkgram.y" /* yacc.c:1646 */ +#line 338 "awkgram.y" /* yacc.c:1646 */ { static int begin_seen = 0; @@ -2049,11 +2046,11 @@ yyreduce: (yyvsp[0])->source_file = source; (yyval) = (yyvsp[0]); } -#line 2053 "awkgram.c" /* yacc.c:1646 */ +#line 2050 "awkgram.c" /* yacc.c:1646 */ break; case 22: -#line 354 "awkgram.y" /* yacc.c:1646 */ +#line 351 "awkgram.y" /* yacc.c:1646 */ { static int end_seen = 0; @@ -2066,74 +2063,80 @@ yyreduce: (yyvsp[0])->source_file = source; (yyval) = (yyvsp[0]); } -#line 2070 "awkgram.c" /* yacc.c:1646 */ +#line 2067 "awkgram.c" /* yacc.c:1646 */ break; case 23: -#line 367 "awkgram.y" /* yacc.c:1646 */ +#line 364 "awkgram.y" /* yacc.c:1646 */ { func_first = false; (yyvsp[0])->in_rule = rule = BEGINFILE; (yyvsp[0])->source_file = source; (yyval) = (yyvsp[0]); } -#line 2081 "awkgram.c" /* yacc.c:1646 */ +#line 2078 "awkgram.c" /* yacc.c:1646 */ break; case 24: -#line 374 "awkgram.y" /* yacc.c:1646 */ +#line 371 "awkgram.y" /* yacc.c:1646 */ { func_first = false; (yyvsp[0])->in_rule = rule = ENDFILE; (yyvsp[0])->source_file = source; (yyval) = (yyvsp[0]); } -#line 2092 "awkgram.c" /* yacc.c:1646 */ +#line 2089 "awkgram.c" /* yacc.c:1646 */ break; case 25: -#line 384 "awkgram.y" /* yacc.c:1646 */ +#line 381 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *ip; + INSTRUCTION *tp; if ((yyvsp[-3]) == NULL) ip = list_create(instruction(Op_no_op)); - else - ip = (yyvsp[-3]); + else { + if (do_pretty_print) { + tp = bcalloc(Op_no_op, 1, lastline); + ip = list_append((yyvsp[-3]), tp); + } else + ip = (yyvsp[-3]); + } (yyval) = ip; } -#line 2105 "awkgram.c" /* yacc.c:1646 */ +#line 2108 "awkgram.c" /* yacc.c:1646 */ break; case 26: -#line 396 "awkgram.y" /* yacc.c:1646 */ +#line 399 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2111 "awkgram.c" /* yacc.c:1646 */ +#line 2114 "awkgram.c" /* yacc.c:1646 */ break; case 27: -#line 398 "awkgram.y" /* yacc.c:1646 */ +#line 401 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2117 "awkgram.c" /* yacc.c:1646 */ +#line 2120 "awkgram.c" /* yacc.c:1646 */ break; case 28: -#line 400 "awkgram.y" /* yacc.c:1646 */ +#line 403 "awkgram.y" /* yacc.c:1646 */ { yyerror(_("`%s' is a built-in function, it cannot be redefined"), tokstart); YYABORT; } -#line 2127 "awkgram.c" /* yacc.c:1646 */ +#line 2130 "awkgram.c" /* yacc.c:1646 */ break; case 29: -#line 406 "awkgram.y" /* yacc.c:1646 */ +#line 409 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2133 "awkgram.c" /* yacc.c:1646 */ +#line 2136 "awkgram.c" /* yacc.c:1646 */ break; case 32: -#line 416 "awkgram.y" /* yacc.c:1646 */ +#line 419 "awkgram.y" /* yacc.c:1646 */ { /* * treat any comments between BOF and the first function @@ -2142,14 +2145,10 @@ yyreduce: * than one such comments, treat the last as a function * comment. */ - if (comment != NULL && func_first - && strstr(comment->memory->stptr, "\n\n") != NULL) + current_comment_type = 1; + if (last_comment != NULL && func_first + && strstr(last_comment->comment_text->stptr, "\n\n") != NULL) split_comment(); - /* save any other pre-function comment as function comment */ - if (comment != NULL) { - function_comment = comment; - comment = NULL; - } func_first = false; (yyvsp[-5])->source_file = source; if (install_function((yyvsp[-4])->lextok, (yyvsp[-5]), (yyvsp[-2])) < 0) @@ -2160,17 +2159,17 @@ yyreduce: /* $4 already free'd in install_function */ (yyval) = (yyvsp[-5]); } -#line 2164 "awkgram.c" /* yacc.c:1646 */ +#line 2163 "awkgram.c" /* yacc.c:1646 */ break; case 33: -#line 450 "awkgram.y" /* yacc.c:1646 */ +#line 449 "awkgram.y" /* yacc.c:1646 */ { want_regexp = true; } -#line 2170 "awkgram.c" /* yacc.c:1646 */ +#line 2169 "awkgram.c" /* yacc.c:1646 */ break; case 34: -#line 452 "awkgram.y" /* yacc.c:1646 */ +#line 451 "awkgram.y" /* yacc.c:1646 */ { NODE *n, *exp; char *re; @@ -2199,89 +2198,72 @@ yyreduce: (yyval)->opcode = Op_match_rec; (yyval)->memory = n; } -#line 2203 "awkgram.c" /* yacc.c:1646 */ +#line 2202 "awkgram.c" /* yacc.c:1646 */ break; case 35: -#line 484 "awkgram.y" /* yacc.c:1646 */ +#line 483 "awkgram.y" /* yacc.c:1646 */ { bcfree((yyvsp[0])); } -#line 2209 "awkgram.c" /* yacc.c:1646 */ +#line 2208 "awkgram.c" /* yacc.c:1646 */ break; case 37: -#line 490 "awkgram.y" /* yacc.c:1646 */ +#line 489 "awkgram.y" /* yacc.c:1646 */ { - if (comment != NULL) { - (yyval) = list_create(comment); - comment = NULL; - } else (yyval) = NULL; + (yyval) = NULL; } -#line 2220 "awkgram.c" /* yacc.c:1646 */ +#line 2216 "awkgram.c" /* yacc.c:1646 */ break; case 38: -#line 497 "awkgram.y" /* yacc.c:1646 */ +#line 493 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[0]) == NULL) { - if (comment == NULL) - (yyval) = (yyvsp[-1]); - else { - (yyval) = list_append((yyvsp[-1]), comment); - comment = NULL; - } + (yyval) = (yyvsp[-1]); } else { add_lint((yyvsp[0]), LINT_no_effect); if ((yyvsp[-1]) == NULL) { - if (comment == NULL) - (yyval) = (yyvsp[0]); - else { - (yyval) = list_append((yyvsp[0]), comment); - comment = NULL; - } + (yyval) = (yyvsp[0]); } else { - if (comment != NULL) { - list_append((yyvsp[0]), comment); - comment = NULL; - } (yyval) = list_merge((yyvsp[-1]), (yyvsp[0])); } } yyerrok; } -#line 2252 "awkgram.c" /* yacc.c:1646 */ +#line 2234 "awkgram.c" /* yacc.c:1646 */ break; case 39: -#line 525 "awkgram.y" /* yacc.c:1646 */ +#line 507 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2258 "awkgram.c" /* yacc.c:1646 */ +#line 2240 "awkgram.c" /* yacc.c:1646 */ break; case 42: -#line 535 "awkgram.y" /* yacc.c:1646 */ +#line 517 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2264 "awkgram.c" /* yacc.c:1646 */ +#line 2246 "awkgram.c" /* yacc.c:1646 */ break; case 43: -#line 537 "awkgram.y" /* yacc.c:1646 */ +#line 519 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 2270 "awkgram.c" /* yacc.c:1646 */ +#line 2252 "awkgram.c" /* yacc.c:1646 */ break; case 44: -#line 539 "awkgram.y" /* yacc.c:1646 */ +#line 521 "awkgram.y" /* yacc.c:1646 */ { if (do_pretty_print) (yyval) = list_prepend((yyvsp[0]), instruction(Op_exec_count)); else (yyval) = (yyvsp[0]); } -#line 2281 "awkgram.c" /* yacc.c:1646 */ +#line 2263 "awkgram.c" /* yacc.c:1646 */ break; case 45: -#line 546 "awkgram.y" /* yacc.c:1646 */ +#line 528 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *dflt, *curr = NULL, *cexp, *cstmt; INSTRUCTION *ip, *nextc, *tbreak; @@ -2371,11 +2353,11 @@ yyreduce: break_allowed--; fix_break_continue(ip, tbreak, NULL); } -#line 2375 "awkgram.c" /* yacc.c:1646 */ +#line 2357 "awkgram.c" /* yacc.c:1646 */ break; case 46: -#line 636 "awkgram.y" /* yacc.c:1646 */ +#line 618 "awkgram.y" /* yacc.c:1646 */ { /* * ----------------- @@ -2417,11 +2399,11 @@ yyreduce: continue_allowed--; fix_break_continue(ip, tbreak, tcont); } -#line 2421 "awkgram.c" /* yacc.c:1646 */ +#line 2403 "awkgram.c" /* yacc.c:1646 */ break; case 47: -#line 678 "awkgram.y" /* yacc.c:1646 */ +#line 660 "awkgram.y" /* yacc.c:1646 */ { /* * ----------------- @@ -2463,11 +2445,11 @@ yyreduce: } /* else $1 and $4 are NULLs */ } -#line 2467 "awkgram.c" /* yacc.c:1646 */ +#line 2449 "awkgram.c" /* yacc.c:1646 */ break; case 48: -#line 720 "awkgram.y" /* yacc.c:1646 */ +#line 702 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *ip; char *var_name = (yyvsp[-5])->lextok; @@ -2580,44 +2562,44 @@ regular_loop: break_allowed--; continue_allowed--; } -#line 2584 "awkgram.c" /* yacc.c:1646 */ +#line 2566 "awkgram.c" /* yacc.c:1646 */ break; case 49: -#line 833 "awkgram.y" /* yacc.c:1646 */ +#line 815 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_for_loop((yyvsp[-11]), (yyvsp[-9]), (yyvsp[-6]), (yyvsp[-3]), (yyvsp[0])); break_allowed--; continue_allowed--; } -#line 2595 "awkgram.c" /* yacc.c:1646 */ +#line 2577 "awkgram.c" /* yacc.c:1646 */ break; case 50: -#line 840 "awkgram.y" /* yacc.c:1646 */ +#line 822 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_for_loop((yyvsp[-10]), (yyvsp[-8]), (INSTRUCTION *) NULL, (yyvsp[-3]), (yyvsp[0])); break_allowed--; continue_allowed--; } -#line 2606 "awkgram.c" /* yacc.c:1646 */ +#line 2588 "awkgram.c" /* yacc.c:1646 */ break; case 51: -#line 847 "awkgram.y" /* yacc.c:1646 */ +#line 829 "awkgram.y" /* yacc.c:1646 */ { if (do_pretty_print) (yyval) = list_prepend((yyvsp[0]), instruction(Op_exec_count)); else (yyval) = (yyvsp[0]); } -#line 2617 "awkgram.c" /* yacc.c:1646 */ +#line 2599 "awkgram.c" /* yacc.c:1646 */ break; case 52: -#line 857 "awkgram.y" /* yacc.c:1646 */ +#line 839 "awkgram.y" /* yacc.c:1646 */ { if (! break_allowed) error_ln((yyvsp[-1])->source_line, @@ -2626,11 +2608,11 @@ regular_loop: (yyval) = list_create((yyvsp[-1])); } -#line 2630 "awkgram.c" /* yacc.c:1646 */ +#line 2612 "awkgram.c" /* yacc.c:1646 */ break; case 53: -#line 866 "awkgram.y" /* yacc.c:1646 */ +#line 848 "awkgram.y" /* yacc.c:1646 */ { if (! continue_allowed) error_ln((yyvsp[-1])->source_line, @@ -2639,11 +2621,11 @@ regular_loop: (yyval) = list_create((yyvsp[-1])); } -#line 2643 "awkgram.c" /* yacc.c:1646 */ +#line 2625 "awkgram.c" /* yacc.c:1646 */ break; case 54: -#line 875 "awkgram.y" /* yacc.c:1646 */ +#line 857 "awkgram.y" /* yacc.c:1646 */ { /* if inside function (rule = 0), resolve context at run-time */ if (rule && rule != Rule) @@ -2652,11 +2634,11 @@ regular_loop: (yyvsp[-1])->target_jmp = ip_rec; (yyval) = list_create((yyvsp[-1])); } -#line 2656 "awkgram.c" /* yacc.c:1646 */ +#line 2638 "awkgram.c" /* yacc.c:1646 */ break; case 55: -#line 884 "awkgram.y" /* yacc.c:1646 */ +#line 866 "awkgram.y" /* yacc.c:1646 */ { /* if inside function (rule = 0), resolve context at run-time */ if (rule == BEGIN || rule == END || rule == ENDFILE) @@ -2667,11 +2649,11 @@ regular_loop: (yyvsp[-1])->target_endfile = ip_endfile; (yyval) = list_create((yyvsp[-1])); } -#line 2671 "awkgram.c" /* yacc.c:1646 */ +#line 2653 "awkgram.c" /* yacc.c:1646 */ break; case 56: -#line 895 "awkgram.y" /* yacc.c:1646 */ +#line 877 "awkgram.y" /* yacc.c:1646 */ { /* Initialize the two possible jump targets, the actual target * is resolved at run-time. @@ -2686,20 +2668,20 @@ regular_loop: } else (yyval) = list_append((yyvsp[-1]), (yyvsp[-2])); } -#line 2690 "awkgram.c" /* yacc.c:1646 */ +#line 2672 "awkgram.c" /* yacc.c:1646 */ break; case 57: -#line 910 "awkgram.y" /* yacc.c:1646 */ +#line 892 "awkgram.y" /* yacc.c:1646 */ { if (! in_function) yyerror(_("`return' used outside function context")); } -#line 2699 "awkgram.c" /* yacc.c:1646 */ +#line 2681 "awkgram.c" /* yacc.c:1646 */ break; case 58: -#line 913 "awkgram.y" /* yacc.c:1646 */ +#line 895 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-1]) == NULL) { (yyval) = list_create((yyvsp[-3])); @@ -2720,17 +2702,17 @@ regular_loop: (yyval) = list_append((yyvsp[-1]), (yyvsp[-3])); } } -#line 2724 "awkgram.c" /* yacc.c:1646 */ +#line 2706 "awkgram.c" /* yacc.c:1646 */ break; case 60: -#line 945 "awkgram.y" /* yacc.c:1646 */ +#line 927 "awkgram.y" /* yacc.c:1646 */ { in_print = true; in_parens = 0; } -#line 2730 "awkgram.c" /* yacc.c:1646 */ +#line 2712 "awkgram.c" /* yacc.c:1646 */ break; case 61: -#line 946 "awkgram.y" /* yacc.c:1646 */ +#line 928 "awkgram.y" /* yacc.c:1646 */ { /* * Optimization: plain `print' has no expression list, so $3 is null. @@ -2827,17 +2809,17 @@ regular_print: } } } -#line 2831 "awkgram.c" /* yacc.c:1646 */ +#line 2813 "awkgram.c" /* yacc.c:1646 */ break; case 62: -#line 1043 "awkgram.y" /* yacc.c:1646 */ +#line 1025 "awkgram.y" /* yacc.c:1646 */ { sub_counter = 0; } -#line 2837 "awkgram.c" /* yacc.c:1646 */ +#line 2819 "awkgram.c" /* yacc.c:1646 */ break; case 63: -#line 1044 "awkgram.y" /* yacc.c:1646 */ +#line 1026 "awkgram.y" /* yacc.c:1646 */ { char *arr = (yyvsp[-2])->lextok; @@ -2870,11 +2852,11 @@ regular_print: (yyval) = list_append(list_append((yyvsp[0]), (yyvsp[-2])), (yyvsp[-3])); } } -#line 2874 "awkgram.c" /* yacc.c:1646 */ +#line 2856 "awkgram.c" /* yacc.c:1646 */ break; case 64: -#line 1081 "awkgram.y" /* yacc.c:1646 */ +#line 1063 "awkgram.y" /* yacc.c:1646 */ { static bool warned = false; char *arr = (yyvsp[-1])->lextok; @@ -2900,52 +2882,52 @@ regular_print: fatal(_("`delete' is not allowed with FUNCTAB")); } } -#line 2904 "awkgram.c" /* yacc.c:1646 */ +#line 2886 "awkgram.c" /* yacc.c:1646 */ break; case 65: -#line 1107 "awkgram.y" /* yacc.c:1646 */ +#line 1089 "awkgram.y" /* yacc.c:1646 */ { (yyval) = optimize_assignment((yyvsp[0])); } -#line 2910 "awkgram.c" /* yacc.c:1646 */ +#line 2892 "awkgram.c" /* yacc.c:1646 */ break; case 66: -#line 1112 "awkgram.y" /* yacc.c:1646 */ +#line 1094 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2916 "awkgram.c" /* yacc.c:1646 */ +#line 2898 "awkgram.c" /* yacc.c:1646 */ break; case 67: -#line 1114 "awkgram.y" /* yacc.c:1646 */ +#line 1096 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2922 "awkgram.c" /* yacc.c:1646 */ +#line 2904 "awkgram.c" /* yacc.c:1646 */ break; case 68: -#line 1119 "awkgram.y" /* yacc.c:1646 */ +#line 1101 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2928 "awkgram.c" /* yacc.c:1646 */ +#line 2910 "awkgram.c" /* yacc.c:1646 */ break; case 69: -#line 1121 "awkgram.y" /* yacc.c:1646 */ +#line 1103 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-1]) == NULL) (yyval) = list_create((yyvsp[0])); else (yyval) = list_prepend((yyvsp[-1]), (yyvsp[0])); } -#line 2939 "awkgram.c" /* yacc.c:1646 */ +#line 2921 "awkgram.c" /* yacc.c:1646 */ break; case 70: -#line 1128 "awkgram.y" /* yacc.c:1646 */ +#line 1110 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2945 "awkgram.c" /* yacc.c:1646 */ +#line 2927 "awkgram.c" /* yacc.c:1646 */ break; case 71: -#line 1133 "awkgram.y" /* yacc.c:1646 */ +#line 1115 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *casestmt = (yyvsp[0]); if ((yyvsp[0]) == NULL) @@ -2957,11 +2939,11 @@ regular_print: bcfree((yyvsp[-2])); (yyval) = (yyvsp[-4]); } -#line 2961 "awkgram.c" /* yacc.c:1646 */ +#line 2943 "awkgram.c" /* yacc.c:1646 */ break; case 72: -#line 1145 "awkgram.y" /* yacc.c:1646 */ +#line 1127 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *casestmt = (yyvsp[0]); if ((yyvsp[0]) == NULL) @@ -2972,17 +2954,17 @@ regular_print: (yyvsp[-3])->case_stmt = casestmt; (yyval) = (yyvsp[-3]); } -#line 2976 "awkgram.c" /* yacc.c:1646 */ +#line 2958 "awkgram.c" /* yacc.c:1646 */ break; case 73: -#line 1159 "awkgram.y" /* yacc.c:1646 */ +#line 1141 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2982 "awkgram.c" /* yacc.c:1646 */ +#line 2964 "awkgram.c" /* yacc.c:1646 */ break; case 74: -#line 1161 "awkgram.y" /* yacc.c:1646 */ +#line 1143 "awkgram.y" /* yacc.c:1646 */ { NODE *n = (yyvsp[0])->memory; (void) force_number(n); @@ -2990,71 +2972,71 @@ regular_print: bcfree((yyvsp[-1])); (yyval) = (yyvsp[0]); } -#line 2994 "awkgram.c" /* yacc.c:1646 */ +#line 2976 "awkgram.c" /* yacc.c:1646 */ break; case 75: -#line 1169 "awkgram.y" /* yacc.c:1646 */ +#line 1151 "awkgram.y" /* yacc.c:1646 */ { bcfree((yyvsp[-1])); (yyval) = (yyvsp[0]); } -#line 3003 "awkgram.c" /* yacc.c:1646 */ +#line 2985 "awkgram.c" /* yacc.c:1646 */ break; case 76: -#line 1174 "awkgram.y" /* yacc.c:1646 */ +#line 1156 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3009 "awkgram.c" /* yacc.c:1646 */ +#line 2991 "awkgram.c" /* yacc.c:1646 */ break; case 77: -#line 1176 "awkgram.y" /* yacc.c:1646 */ +#line 1158 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_push_re; (yyval) = (yyvsp[0]); } -#line 3018 "awkgram.c" /* yacc.c:1646 */ +#line 3000 "awkgram.c" /* yacc.c:1646 */ break; case 78: -#line 1184 "awkgram.y" /* yacc.c:1646 */ +#line 1166 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3024 "awkgram.c" /* yacc.c:1646 */ +#line 3006 "awkgram.c" /* yacc.c:1646 */ break; case 79: -#line 1186 "awkgram.y" /* yacc.c:1646 */ +#line 1168 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3030 "awkgram.c" /* yacc.c:1646 */ +#line 3012 "awkgram.c" /* yacc.c:1646 */ break; case 81: -#line 1196 "awkgram.y" /* yacc.c:1646 */ +#line 1178 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3038 "awkgram.c" /* yacc.c:1646 */ +#line 3020 "awkgram.c" /* yacc.c:1646 */ break; case 82: -#line 1203 "awkgram.y" /* yacc.c:1646 */ +#line 1185 "awkgram.y" /* yacc.c:1646 */ { in_print = false; in_parens = 0; (yyval) = NULL; } -#line 3048 "awkgram.c" /* yacc.c:1646 */ +#line 3030 "awkgram.c" /* yacc.c:1646 */ break; case 83: -#line 1208 "awkgram.y" /* yacc.c:1646 */ +#line 1190 "awkgram.y" /* yacc.c:1646 */ { in_print = false; in_parens = 0; } -#line 3054 "awkgram.c" /* yacc.c:1646 */ +#line 3036 "awkgram.c" /* yacc.c:1646 */ break; case 84: -#line 1209 "awkgram.y" /* yacc.c:1646 */ +#line 1191 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-2])->redir_type == redirect_twoway && (yyvsp[0])->lasti->opcode == Op_K_getline_redir @@ -3062,136 +3044,136 @@ regular_print: yyerror(_("multistage two-way pipelines don't work")); (yyval) = list_prepend((yyvsp[0]), (yyvsp[-2])); } -#line 3066 "awkgram.c" /* yacc.c:1646 */ +#line 3048 "awkgram.c" /* yacc.c:1646 */ break; case 85: -#line 1220 "awkgram.y" /* yacc.c:1646 */ +#line 1202 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_condition((yyvsp[-3]), (yyvsp[-5]), (yyvsp[0]), NULL, NULL); } -#line 3074 "awkgram.c" /* yacc.c:1646 */ +#line 3056 "awkgram.c" /* yacc.c:1646 */ break; case 86: -#line 1225 "awkgram.y" /* yacc.c:1646 */ +#line 1207 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_condition((yyvsp[-6]), (yyvsp[-8]), (yyvsp[-3]), (yyvsp[-2]), (yyvsp[0])); } -#line 3082 "awkgram.c" /* yacc.c:1646 */ +#line 3064 "awkgram.c" /* yacc.c:1646 */ break; case 91: -#line 1242 "awkgram.y" /* yacc.c:1646 */ +#line 1224 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3088 "awkgram.c" /* yacc.c:1646 */ +#line 3070 "awkgram.c" /* yacc.c:1646 */ break; case 92: -#line 1244 "awkgram.y" /* yacc.c:1646 */ +#line 1226 "awkgram.y" /* yacc.c:1646 */ { bcfree((yyvsp[-1])); (yyval) = (yyvsp[0]); } -#line 3097 "awkgram.c" /* yacc.c:1646 */ +#line 3079 "awkgram.c" /* yacc.c:1646 */ break; case 93: -#line 1252 "awkgram.y" /* yacc.c:1646 */ +#line 1234 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3103 "awkgram.c" /* yacc.c:1646 */ +#line 3085 "awkgram.c" /* yacc.c:1646 */ break; case 94: -#line 1254 "awkgram.y" /* yacc.c:1646 */ +#line 1236 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3109 "awkgram.c" /* yacc.c:1646 */ +#line 3091 "awkgram.c" /* yacc.c:1646 */ break; case 95: -#line 1259 "awkgram.y" /* yacc.c:1646 */ +#line 1241 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->param_count = 0; (yyval) = list_create((yyvsp[0])); } -#line 3118 "awkgram.c" /* yacc.c:1646 */ +#line 3100 "awkgram.c" /* yacc.c:1646 */ break; case 96: -#line 1264 "awkgram.y" /* yacc.c:1646 */ +#line 1246 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->param_count = (yyvsp[-2])->lasti->param_count + 1; (yyval) = list_append((yyvsp[-2]), (yyvsp[0])); yyerrok; } -#line 3128 "awkgram.c" /* yacc.c:1646 */ +#line 3110 "awkgram.c" /* yacc.c:1646 */ break; case 97: -#line 1270 "awkgram.y" /* yacc.c:1646 */ +#line 1252 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3134 "awkgram.c" /* yacc.c:1646 */ +#line 3116 "awkgram.c" /* yacc.c:1646 */ break; case 98: -#line 1272 "awkgram.y" /* yacc.c:1646 */ +#line 1254 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3140 "awkgram.c" /* yacc.c:1646 */ +#line 3122 "awkgram.c" /* yacc.c:1646 */ break; case 99: -#line 1274 "awkgram.y" /* yacc.c:1646 */ +#line 1256 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-2]); } -#line 3146 "awkgram.c" /* yacc.c:1646 */ +#line 3128 "awkgram.c" /* yacc.c:1646 */ break; case 100: -#line 1280 "awkgram.y" /* yacc.c:1646 */ +#line 1262 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3152 "awkgram.c" /* yacc.c:1646 */ +#line 3134 "awkgram.c" /* yacc.c:1646 */ break; case 101: -#line 1282 "awkgram.y" /* yacc.c:1646 */ +#line 1264 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3158 "awkgram.c" /* yacc.c:1646 */ +#line 3140 "awkgram.c" /* yacc.c:1646 */ break; case 102: -#line 1287 "awkgram.y" /* yacc.c:1646 */ +#line 1269 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3164 "awkgram.c" /* yacc.c:1646 */ +#line 3146 "awkgram.c" /* yacc.c:1646 */ break; case 103: -#line 1289 "awkgram.y" /* yacc.c:1646 */ +#line 1271 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3170 "awkgram.c" /* yacc.c:1646 */ +#line 3152 "awkgram.c" /* yacc.c:1646 */ break; case 104: -#line 1294 "awkgram.y" /* yacc.c:1646 */ +#line 1276 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_expression_list(NULL, (yyvsp[0])); } -#line 3176 "awkgram.c" /* yacc.c:1646 */ +#line 3158 "awkgram.c" /* yacc.c:1646 */ break; case 105: -#line 1296 "awkgram.y" /* yacc.c:1646 */ +#line 1278 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0])); yyerrok; } -#line 3185 "awkgram.c" /* yacc.c:1646 */ +#line 3167 "awkgram.c" /* yacc.c:1646 */ break; case 106: -#line 1301 "awkgram.y" /* yacc.c:1646 */ +#line 1283 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3191 "awkgram.c" /* yacc.c:1646 */ +#line 3173 "awkgram.c" /* yacc.c:1646 */ break; case 107: -#line 1303 "awkgram.y" /* yacc.c:1646 */ +#line 1285 "awkgram.y" /* yacc.c:1646 */ { /* * Returning the expression list instead of NULL lets @@ -3199,52 +3181,52 @@ regular_print: */ (yyval) = (yyvsp[-1]); } -#line 3203 "awkgram.c" /* yacc.c:1646 */ +#line 3185 "awkgram.c" /* yacc.c:1646 */ break; case 108: -#line 1311 "awkgram.y" /* yacc.c:1646 */ +#line 1293 "awkgram.y" /* yacc.c:1646 */ { /* Ditto */ (yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0])); } -#line 3212 "awkgram.c" /* yacc.c:1646 */ +#line 3194 "awkgram.c" /* yacc.c:1646 */ break; case 109: -#line 1316 "awkgram.y" /* yacc.c:1646 */ +#line 1298 "awkgram.y" /* yacc.c:1646 */ { /* Ditto */ (yyval) = (yyvsp[-2]); } -#line 3221 "awkgram.c" /* yacc.c:1646 */ +#line 3203 "awkgram.c" /* yacc.c:1646 */ break; case 110: -#line 1325 "awkgram.y" /* yacc.c:1646 */ +#line 1307 "awkgram.y" /* yacc.c:1646 */ { if (do_lint && (yyvsp[0])->lasti->opcode == Op_match_rec) lintwarn_ln((yyvsp[-1])->source_line, _("regular expression on right of assignment")); (yyval) = mk_assignment((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3232 "awkgram.c" /* yacc.c:1646 */ +#line 3214 "awkgram.c" /* yacc.c:1646 */ break; case 111: -#line 1332 "awkgram.y" /* yacc.c:1646 */ +#line 1314 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3238 "awkgram.c" /* yacc.c:1646 */ +#line 3220 "awkgram.c" /* yacc.c:1646 */ break; case 112: -#line 1334 "awkgram.y" /* yacc.c:1646 */ +#line 1316 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3244 "awkgram.c" /* yacc.c:1646 */ +#line 3226 "awkgram.c" /* yacc.c:1646 */ break; case 113: -#line 1336 "awkgram.y" /* yacc.c:1646 */ +#line 1318 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-2])->lasti->opcode == Op_match_rec) warning_ln((yyvsp[-1])->source_line, @@ -3260,11 +3242,11 @@ regular_print: (yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1])); } } -#line 3264 "awkgram.c" /* yacc.c:1646 */ +#line 3246 "awkgram.c" /* yacc.c:1646 */ break; case 114: -#line 1352 "awkgram.y" /* yacc.c:1646 */ +#line 1334 "awkgram.y" /* yacc.c:1646 */ { if (do_lint_old) warning_ln((yyvsp[-1])->source_line, @@ -3274,91 +3256,91 @@ regular_print: (yyvsp[-1])->expr_count = 1; (yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1])); } -#line 3278 "awkgram.c" /* yacc.c:1646 */ +#line 3260 "awkgram.c" /* yacc.c:1646 */ break; case 115: -#line 1362 "awkgram.y" /* yacc.c:1646 */ +#line 1344 "awkgram.y" /* yacc.c:1646 */ { if (do_lint && (yyvsp[0])->lasti->opcode == Op_match_rec) lintwarn_ln((yyvsp[-1])->source_line, _("regular expression on right of comparison")); (yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1])); } -#line 3289 "awkgram.c" /* yacc.c:1646 */ +#line 3271 "awkgram.c" /* yacc.c:1646 */ break; case 116: -#line 1369 "awkgram.y" /* yacc.c:1646 */ +#line 1351 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_condition((yyvsp[-4]), (yyvsp[-3]), (yyvsp[-2]), (yyvsp[-1]), (yyvsp[0])); } -#line 3295 "awkgram.c" /* yacc.c:1646 */ +#line 3277 "awkgram.c" /* yacc.c:1646 */ break; case 117: -#line 1371 "awkgram.y" /* yacc.c:1646 */ +#line 1353 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3301 "awkgram.c" /* yacc.c:1646 */ +#line 3283 "awkgram.c" /* yacc.c:1646 */ break; case 118: -#line 1376 "awkgram.y" /* yacc.c:1646 */ +#line 1358 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3307 "awkgram.c" /* yacc.c:1646 */ +#line 3289 "awkgram.c" /* yacc.c:1646 */ break; case 119: -#line 1378 "awkgram.y" /* yacc.c:1646 */ +#line 1360 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3313 "awkgram.c" /* yacc.c:1646 */ +#line 3295 "awkgram.c" /* yacc.c:1646 */ break; case 120: -#line 1380 "awkgram.y" /* yacc.c:1646 */ +#line 1362 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_assign_quotient; (yyval) = (yyvsp[0]); } -#line 3322 "awkgram.c" /* yacc.c:1646 */ +#line 3304 "awkgram.c" /* yacc.c:1646 */ break; case 121: -#line 1388 "awkgram.y" /* yacc.c:1646 */ +#line 1370 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3328 "awkgram.c" /* yacc.c:1646 */ +#line 3310 "awkgram.c" /* yacc.c:1646 */ break; case 122: -#line 1390 "awkgram.y" /* yacc.c:1646 */ +#line 1372 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3334 "awkgram.c" /* yacc.c:1646 */ +#line 3316 "awkgram.c" /* yacc.c:1646 */ break; case 123: -#line 1395 "awkgram.y" /* yacc.c:1646 */ +#line 1377 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3340 "awkgram.c" /* yacc.c:1646 */ +#line 3322 "awkgram.c" /* yacc.c:1646 */ break; case 124: -#line 1397 "awkgram.y" /* yacc.c:1646 */ +#line 1379 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3346 "awkgram.c" /* yacc.c:1646 */ +#line 3328 "awkgram.c" /* yacc.c:1646 */ break; case 125: -#line 1402 "awkgram.y" /* yacc.c:1646 */ +#line 1384 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3352 "awkgram.c" /* yacc.c:1646 */ +#line 3334 "awkgram.c" /* yacc.c:1646 */ break; case 126: -#line 1404 "awkgram.y" /* yacc.c:1646 */ +#line 1386 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3358 "awkgram.c" /* yacc.c:1646 */ +#line 3340 "awkgram.c" /* yacc.c:1646 */ break; case 127: -#line 1406 "awkgram.y" /* yacc.c:1646 */ +#line 1388 "awkgram.y" /* yacc.c:1646 */ { int count = 2; bool is_simple_var = false; @@ -3405,47 +3387,47 @@ regular_print: max_args = count; } } -#line 3409 "awkgram.c" /* yacc.c:1646 */ +#line 3391 "awkgram.c" /* yacc.c:1646 */ break; case 129: -#line 1458 "awkgram.y" /* yacc.c:1646 */ +#line 1440 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3415 "awkgram.c" /* yacc.c:1646 */ +#line 3397 "awkgram.c" /* yacc.c:1646 */ break; case 130: -#line 1460 "awkgram.y" /* yacc.c:1646 */ +#line 1442 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3421 "awkgram.c" /* yacc.c:1646 */ +#line 3403 "awkgram.c" /* yacc.c:1646 */ break; case 131: -#line 1462 "awkgram.y" /* yacc.c:1646 */ +#line 1444 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3427 "awkgram.c" /* yacc.c:1646 */ +#line 3409 "awkgram.c" /* yacc.c:1646 */ break; case 132: -#line 1464 "awkgram.y" /* yacc.c:1646 */ +#line 1446 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3433 "awkgram.c" /* yacc.c:1646 */ +#line 3415 "awkgram.c" /* yacc.c:1646 */ break; case 133: -#line 1466 "awkgram.y" /* yacc.c:1646 */ +#line 1448 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3439 "awkgram.c" /* yacc.c:1646 */ +#line 3421 "awkgram.c" /* yacc.c:1646 */ break; case 134: -#line 1468 "awkgram.y" /* yacc.c:1646 */ +#line 1450 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3445 "awkgram.c" /* yacc.c:1646 */ +#line 3427 "awkgram.c" /* yacc.c:1646 */ break; case 135: -#line 1470 "awkgram.y" /* yacc.c:1646 */ +#line 1452 "awkgram.y" /* yacc.c:1646 */ { /* * In BEGINFILE/ENDFILE, allow `getline [var] < file' @@ -3459,29 +3441,29 @@ regular_print: _("non-redirected `getline' undefined inside END action")); (yyval) = mk_getline((yyvsp[-2]), (yyvsp[-1]), (yyvsp[0]), redirect_input); } -#line 3463 "awkgram.c" /* yacc.c:1646 */ +#line 3445 "awkgram.c" /* yacc.c:1646 */ break; case 136: -#line 1484 "awkgram.y" /* yacc.c:1646 */ +#line 1466 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postincrement; (yyval) = mk_assignment((yyvsp[-1]), NULL, (yyvsp[0])); } -#line 3472 "awkgram.c" /* yacc.c:1646 */ +#line 3454 "awkgram.c" /* yacc.c:1646 */ break; case 137: -#line 1489 "awkgram.y" /* yacc.c:1646 */ +#line 1471 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postdecrement; (yyval) = mk_assignment((yyvsp[-1]), NULL, (yyvsp[0])); } -#line 3481 "awkgram.c" /* yacc.c:1646 */ +#line 3463 "awkgram.c" /* yacc.c:1646 */ break; case 138: -#line 1494 "awkgram.y" /* yacc.c:1646 */ +#line 1476 "awkgram.y" /* yacc.c:1646 */ { if (do_lint_old) { warning_ln((yyvsp[-1])->source_line, @@ -3501,64 +3483,64 @@ regular_print: (yyval) = list_append(list_merge(t, (yyvsp[0])), (yyvsp[-1])); } } -#line 3505 "awkgram.c" /* yacc.c:1646 */ +#line 3487 "awkgram.c" /* yacc.c:1646 */ break; case 139: -#line 1519 "awkgram.y" /* yacc.c:1646 */ +#line 1501 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_getline((yyvsp[-1]), (yyvsp[0]), (yyvsp[-3]), (yyvsp[-2])->redir_type); bcfree((yyvsp[-2])); } -#line 3514 "awkgram.c" /* yacc.c:1646 */ +#line 3496 "awkgram.c" /* yacc.c:1646 */ break; case 140: -#line 1525 "awkgram.y" /* yacc.c:1646 */ +#line 1507 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3520 "awkgram.c" /* yacc.c:1646 */ +#line 3502 "awkgram.c" /* yacc.c:1646 */ break; case 141: -#line 1527 "awkgram.y" /* yacc.c:1646 */ +#line 1509 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3526 "awkgram.c" /* yacc.c:1646 */ +#line 3508 "awkgram.c" /* yacc.c:1646 */ break; case 142: -#line 1529 "awkgram.y" /* yacc.c:1646 */ +#line 1511 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3532 "awkgram.c" /* yacc.c:1646 */ +#line 3514 "awkgram.c" /* yacc.c:1646 */ break; case 143: -#line 1531 "awkgram.y" /* yacc.c:1646 */ +#line 1513 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3538 "awkgram.c" /* yacc.c:1646 */ +#line 3520 "awkgram.c" /* yacc.c:1646 */ break; case 144: -#line 1533 "awkgram.y" /* yacc.c:1646 */ +#line 1515 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3544 "awkgram.c" /* yacc.c:1646 */ +#line 3526 "awkgram.c" /* yacc.c:1646 */ break; case 145: -#line 1535 "awkgram.y" /* yacc.c:1646 */ +#line 1517 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3550 "awkgram.c" /* yacc.c:1646 */ +#line 3532 "awkgram.c" /* yacc.c:1646 */ break; case 146: -#line 1540 "awkgram.y" /* yacc.c:1646 */ +#line 1522 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_create((yyvsp[0])); } -#line 3558 "awkgram.c" /* yacc.c:1646 */ +#line 3540 "awkgram.c" /* yacc.c:1646 */ break; case 147: -#line 1544 "awkgram.y" /* yacc.c:1646 */ +#line 1526 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[0])->opcode == Op_match_rec) { (yyvsp[0])->opcode = Op_nomatch; @@ -3590,37 +3572,37 @@ regular_print: } } } -#line 3594 "awkgram.c" /* yacc.c:1646 */ +#line 3576 "awkgram.c" /* yacc.c:1646 */ break; case 148: -#line 1576 "awkgram.y" /* yacc.c:1646 */ +#line 1558 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3600 "awkgram.c" /* yacc.c:1646 */ +#line 3582 "awkgram.c" /* yacc.c:1646 */ break; case 149: -#line 1578 "awkgram.y" /* yacc.c:1646 */ +#line 1560 "awkgram.y" /* yacc.c:1646 */ { (yyval) = snode((yyvsp[-1]), (yyvsp[-3])); if ((yyval) == NULL) YYABORT; } -#line 3610 "awkgram.c" /* yacc.c:1646 */ +#line 3592 "awkgram.c" /* yacc.c:1646 */ break; case 150: -#line 1584 "awkgram.y" /* yacc.c:1646 */ +#line 1566 "awkgram.y" /* yacc.c:1646 */ { (yyval) = snode((yyvsp[-1]), (yyvsp[-3])); if ((yyval) == NULL) YYABORT; } -#line 3620 "awkgram.c" /* yacc.c:1646 */ +#line 3602 "awkgram.c" /* yacc.c:1646 */ break; case 151: -#line 1590 "awkgram.y" /* yacc.c:1646 */ +#line 1572 "awkgram.y" /* yacc.c:1646 */ { static bool warned = false; @@ -3633,45 +3615,45 @@ regular_print: if ((yyval) == NULL) YYABORT; } -#line 3637 "awkgram.c" /* yacc.c:1646 */ +#line 3619 "awkgram.c" /* yacc.c:1646 */ break; case 154: -#line 1605 "awkgram.y" /* yacc.c:1646 */ +#line 1587 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[-1])->opcode = Op_preincrement; (yyval) = mk_assignment((yyvsp[0]), NULL, (yyvsp[-1])); } -#line 3646 "awkgram.c" /* yacc.c:1646 */ +#line 3628 "awkgram.c" /* yacc.c:1646 */ break; case 155: -#line 1610 "awkgram.y" /* yacc.c:1646 */ +#line 1592 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[-1])->opcode = Op_predecrement; (yyval) = mk_assignment((yyvsp[0]), NULL, (yyvsp[-1])); } -#line 3655 "awkgram.c" /* yacc.c:1646 */ +#line 3637 "awkgram.c" /* yacc.c:1646 */ break; case 156: -#line 1615 "awkgram.y" /* yacc.c:1646 */ +#line 1597 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_create((yyvsp[0])); } -#line 3663 "awkgram.c" /* yacc.c:1646 */ +#line 3645 "awkgram.c" /* yacc.c:1646 */ break; case 157: -#line 1619 "awkgram.y" /* yacc.c:1646 */ +#line 1601 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_create((yyvsp[0])); } -#line 3671 "awkgram.c" /* yacc.c:1646 */ +#line 3653 "awkgram.c" /* yacc.c:1646 */ break; case 158: -#line 1623 "awkgram.y" /* yacc.c:1646 */ +#line 1605 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[0])->lasti->opcode == Op_push_i && ((yyvsp[0])->lasti->memory->flags & (STRCUR|STRING)) == 0 @@ -3686,11 +3668,11 @@ regular_print: (yyval) = list_append((yyvsp[0]), (yyvsp[-1])); } } -#line 3690 "awkgram.c" /* yacc.c:1646 */ +#line 3672 "awkgram.c" /* yacc.c:1646 */ break; case 159: -#line 1638 "awkgram.y" /* yacc.c:1646 */ +#line 1620 "awkgram.y" /* yacc.c:1646 */ { /* * was: $$ = $2 @@ -3700,20 +3682,20 @@ regular_print: (yyvsp[-1])->memory = make_number(0.0); (yyval) = list_append((yyvsp[0]), (yyvsp[-1])); } -#line 3704 "awkgram.c" /* yacc.c:1646 */ +#line 3686 "awkgram.c" /* yacc.c:1646 */ break; case 160: -#line 1651 "awkgram.y" /* yacc.c:1646 */ +#line 1633 "awkgram.y" /* yacc.c:1646 */ { func_use((yyvsp[0])->lasti->func_name, FUNC_USE); (yyval) = (yyvsp[0]); } -#line 3713 "awkgram.c" /* yacc.c:1646 */ +#line 3695 "awkgram.c" /* yacc.c:1646 */ break; case 161: -#line 1656 "awkgram.y" /* yacc.c:1646 */ +#line 1638 "awkgram.y" /* yacc.c:1646 */ { /* indirect function call */ INSTRUCTION *f, *t; @@ -3746,11 +3728,11 @@ regular_print: (yyval) = list_prepend((yyvsp[0]), t); } -#line 3750 "awkgram.c" /* yacc.c:1646 */ +#line 3732 "awkgram.c" /* yacc.c:1646 */ break; case 162: -#line 1692 "awkgram.y" /* yacc.c:1646 */ +#line 1674 "awkgram.y" /* yacc.c:1646 */ { param_sanity((yyvsp[-1])); (yyvsp[-3])->opcode = Op_func_call; @@ -3764,49 +3746,49 @@ regular_print: (yyval) = list_append(t, (yyvsp[-3])); } } -#line 3768 "awkgram.c" /* yacc.c:1646 */ +#line 3750 "awkgram.c" /* yacc.c:1646 */ break; case 163: -#line 1709 "awkgram.y" /* yacc.c:1646 */ +#line 1691 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3774 "awkgram.c" /* yacc.c:1646 */ +#line 3756 "awkgram.c" /* yacc.c:1646 */ break; case 164: -#line 1711 "awkgram.y" /* yacc.c:1646 */ +#line 1693 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3780 "awkgram.c" /* yacc.c:1646 */ +#line 3762 "awkgram.c" /* yacc.c:1646 */ break; case 165: -#line 1716 "awkgram.y" /* yacc.c:1646 */ +#line 1698 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3786 "awkgram.c" /* yacc.c:1646 */ +#line 3768 "awkgram.c" /* yacc.c:1646 */ break; case 166: -#line 1718 "awkgram.y" /* yacc.c:1646 */ +#line 1700 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3792 "awkgram.c" /* yacc.c:1646 */ +#line 3774 "awkgram.c" /* yacc.c:1646 */ break; case 167: -#line 1723 "awkgram.y" /* yacc.c:1646 */ +#line 1705 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3798 "awkgram.c" /* yacc.c:1646 */ +#line 3780 "awkgram.c" /* yacc.c:1646 */ break; case 168: -#line 1725 "awkgram.y" /* yacc.c:1646 */ +#line 1707 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_merge((yyvsp[-1]), (yyvsp[0])); } -#line 3806 "awkgram.c" /* yacc.c:1646 */ +#line 3788 "awkgram.c" /* yacc.c:1646 */ break; case 169: -#line 1732 "awkgram.y" /* yacc.c:1646 */ +#line 1714 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *ip = (yyvsp[0])->lasti; int count = ip->sub_count; /* # of SUBSEP-seperated expressions */ @@ -3820,11 +3802,11 @@ regular_print: sub_counter++; /* count # of dimensions */ (yyval) = (yyvsp[0]); } -#line 3824 "awkgram.c" /* yacc.c:1646 */ +#line 3806 "awkgram.c" /* yacc.c:1646 */ break; case 170: -#line 1749 "awkgram.y" /* yacc.c:1646 */ +#line 1731 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *t = (yyvsp[-1]); if ((yyvsp[-1]) == NULL) { @@ -3838,31 +3820,31 @@ regular_print: (yyvsp[0])->sub_count = count_expressions(&t, false); (yyval) = list_append(t, (yyvsp[0])); } -#line 3842 "awkgram.c" /* yacc.c:1646 */ +#line 3824 "awkgram.c" /* yacc.c:1646 */ break; case 171: -#line 1766 "awkgram.y" /* yacc.c:1646 */ +#line 1748 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3848 "awkgram.c" /* yacc.c:1646 */ +#line 3830 "awkgram.c" /* yacc.c:1646 */ break; case 172: -#line 1768 "awkgram.y" /* yacc.c:1646 */ +#line 1750 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_merge((yyvsp[-1]), (yyvsp[0])); } -#line 3856 "awkgram.c" /* yacc.c:1646 */ +#line 3838 "awkgram.c" /* yacc.c:1646 */ break; case 173: -#line 1775 "awkgram.y" /* yacc.c:1646 */ +#line 1757 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3862 "awkgram.c" /* yacc.c:1646 */ +#line 3844 "awkgram.c" /* yacc.c:1646 */ break; case 174: -#line 1780 "awkgram.y" /* yacc.c:1646 */ +#line 1762 "awkgram.y" /* yacc.c:1646 */ { char *var_name = (yyvsp[0])->lextok; @@ -3870,22 +3852,22 @@ regular_print: (yyvsp[0])->memory = variable((yyvsp[0])->source_line, var_name, Node_var_new); (yyval) = list_create((yyvsp[0])); } -#line 3874 "awkgram.c" /* yacc.c:1646 */ +#line 3856 "awkgram.c" /* yacc.c:1646 */ break; case 175: -#line 1788 "awkgram.y" /* yacc.c:1646 */ +#line 1770 "awkgram.y" /* yacc.c:1646 */ { char *arr = (yyvsp[-1])->lextok; (yyvsp[-1])->memory = variable((yyvsp[-1])->source_line, arr, Node_var_new); (yyvsp[-1])->opcode = Op_push_array; (yyval) = list_prepend((yyvsp[0]), (yyvsp[-1])); } -#line 3885 "awkgram.c" /* yacc.c:1646 */ +#line 3867 "awkgram.c" /* yacc.c:1646 */ break; case 176: -#line 1798 "awkgram.y" /* yacc.c:1646 */ +#line 1780 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *ip = (yyvsp[0])->nexti; if (ip->opcode == Op_push @@ -3897,73 +3879,73 @@ regular_print: } else (yyval) = (yyvsp[0]); } -#line 3901 "awkgram.c" /* yacc.c:1646 */ +#line 3883 "awkgram.c" /* yacc.c:1646 */ break; case 177: -#line 1810 "awkgram.y" /* yacc.c:1646 */ +#line 1792 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_append((yyvsp[-1]), (yyvsp[-2])); if ((yyvsp[0]) != NULL) mk_assignment((yyvsp[-1]), NULL, (yyvsp[0])); } -#line 3911 "awkgram.c" /* yacc.c:1646 */ +#line 3893 "awkgram.c" /* yacc.c:1646 */ break; case 178: -#line 1819 "awkgram.y" /* yacc.c:1646 */ +#line 1801 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postincrement; } -#line 3919 "awkgram.c" /* yacc.c:1646 */ +#line 3901 "awkgram.c" /* yacc.c:1646 */ break; case 179: -#line 1823 "awkgram.y" /* yacc.c:1646 */ +#line 1805 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postdecrement; } -#line 3927 "awkgram.c" /* yacc.c:1646 */ +#line 3909 "awkgram.c" /* yacc.c:1646 */ break; case 180: -#line 1826 "awkgram.y" /* yacc.c:1646 */ +#line 1808 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3933 "awkgram.c" /* yacc.c:1646 */ +#line 3915 "awkgram.c" /* yacc.c:1646 */ break; case 182: -#line 1834 "awkgram.y" /* yacc.c:1646 */ +#line 1816 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3939 "awkgram.c" /* yacc.c:1646 */ +#line 3921 "awkgram.c" /* yacc.c:1646 */ break; case 183: -#line 1838 "awkgram.y" /* yacc.c:1646 */ +#line 1820 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3945 "awkgram.c" /* yacc.c:1646 */ +#line 3927 "awkgram.c" /* yacc.c:1646 */ break; case 186: -#line 1847 "awkgram.y" /* yacc.c:1646 */ +#line 1829 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3951 "awkgram.c" /* yacc.c:1646 */ +#line 3933 "awkgram.c" /* yacc.c:1646 */ break; case 187: -#line 1851 "awkgram.y" /* yacc.c:1646 */ +#line 1833 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); yyerrok; } -#line 3957 "awkgram.c" /* yacc.c:1646 */ +#line 3939 "awkgram.c" /* yacc.c:1646 */ break; case 188: -#line 1855 "awkgram.y" /* yacc.c:1646 */ +#line 1837 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3963 "awkgram.c" /* yacc.c:1646 */ +#line 3945 "awkgram.c" /* yacc.c:1646 */ break; -#line 3967 "awkgram.c" /* yacc.c:1646 */ +#line 3949 "awkgram.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -4191,7 +4173,7 @@ yyreturn: #endif return yyresult; } -#line 1857 "awkgram.y" /* yacc.c:1906 */ +#line 1839 "awkgram.y" /* yacc.c:1906 */ struct token { @@ -4620,13 +4602,6 @@ mk_program() cp = end_block; else cp = list_merge(begin_block, end_block); - /* - * We don't need to clear the comment variables - * since they're not used anymore after this - * function is called. - */ - if (comment != NULL) - (void) list_append(cp, comment); (void) list_append(cp, ip_atexit); (void) list_append(cp, instruction(Op_stop)); @@ -4659,12 +4634,6 @@ mk_program() if (begin_block != NULL) cp = list_merge(begin_block, cp); - if (program_comment != NULL) { - (void) list_prepend(cp, program_comment); - } - if (comment != NULL) { - (void) list_append(cp, comment); - } (void) list_append(cp, ip_atexit); (void) list_append(cp, instruction(Op_stop)); @@ -5314,11 +5283,10 @@ pushback(void) (! lexeof && lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr); } - /* get_comment --- collect comment text */ int -get_comment(void) +get_comment(int flag) { int c; int sl; @@ -5330,6 +5298,12 @@ get_comment(void) while ((c = nextc(false)) != '\n' && c != END_FILE) { tokadd(c); } + if (flag == 1) { + /* comment at end of line. */ + if (c == '\n') + tokadd(c); + break; + } if (c == '\n') { tokadd(c); sourceline++; @@ -5344,6 +5318,7 @@ get_comment(void) break; else if (c != '#') { pushback(); + sourceline--; break; } else tokadd(c); @@ -5351,8 +5326,10 @@ get_comment(void) break; } comment = bcalloc(Op_comment, 1, sl); + comment->comment_text = make_str_node(tokstart, tok - tokstart, 0); comment->source_file = source; - comment->memory = make_str_node(tokstart, tok - tokstart, 0); + comment->comment_text->comment_type = current_comment_type; + append_comment(comment); return c; } @@ -5366,20 +5343,19 @@ split_comment(void) int l; NODE *n; - p = comment->memory->stptr; - l = comment->memory->stlen - 3; + p = last_comment->comment_text->stptr; + l = last_comment->comment_text->stlen - 3; /* have at least two comments so split at last blank line (\n\n) */ while (l >= 0) { if (p[l] == '\n' && p[l+1] == '\n') { - function_comment = comment; - n = function_comment->memory; - function_comment->memory = make_str_node(p + l + 2, n->stlen - l - 2, 0); - /* create program comment */ - program_comment = bcalloc(Op_comment, 1, sourceline); - program_comment->source_file = comment->source_file; + n = last_comment->comment_text; + /* create function comment */ + comment = bcalloc(Op_comment, 1, sourceline); + comment->source_file = source; + comment->comment_text = make_str_node(p + l + 2, n->stlen - l - 2, 0); p[l + 2] = 0; - program_comment->memory = make_str_node(p, l + 2, 0); - comment = NULL; + last_comment->comment_text = make_str_node(p, l + 2, 0); + append_comment(comment); freenode(n); break; } @@ -5388,6 +5364,22 @@ split_comment(void) } } +/* append_comment --- append latest comment to our list of comments */ + +static void +append_comment(INSTRUCTION *ip) +{ + if (first_comment == NULL) { + first_comment = ip; + last_comment = ip; + } else + last_comment->nexti = ip; + + last_comment = ip; + last_comment->nexti = NULL; + ip = NULL; +} + /* allow_newline --- allow newline after &&, ||, ? and : */ static void @@ -5404,7 +5396,7 @@ allow_newline(void) if (c == '#') { if (do_pretty_print && ! do_profile) { /* collect comment byte code iff doing pretty print but not profiling. */ - c = get_comment(); + c = get_comment(1); } else { while ((c = nextc(false)) != '\n' && c != END_FILE) continue; @@ -5616,7 +5608,10 @@ retry: * Collect comment byte code iff doing pretty print * but not profiling. */ - c = get_comment(); + if (lasttok == NEWLINE) + c = get_comment(2); + else + c = get_comment(1); if (c == END_FILE) return lasttok = NEWLINE_EOF; @@ -5653,7 +5648,7 @@ retry: _("use of `\\ #...' line continuation is not portable")); } if (do_pretty_print && ! do_profile) - c = get_comment(); + c = get_comment(2); else { while ((c = nextc(false)) != '\n') if (c == END_FILE) @@ -6671,6 +6666,7 @@ void dump_funcs() { NODE **funcs; + current_comment_type = 1; funcs = function_list(true); (void) foreach_func(funcs, (int (*)(INSTRUCTION *, void *)) pp_func, (void *) 0); efree(funcs); @@ -6723,14 +6719,6 @@ mk_function(INSTRUCTION *fi, INSTRUCTION *def) (t + 1)->tail_call = true; } - /* add any pre-function comment to start of action for profile.c */ - - if (function_comment != NULL) { - function_comment->source_line = 0; - (void) list_prepend(def, function_comment); - function_comment = NULL; - } - /* add an implicit return at end; * also used by 'return' command in debugger */ @@ -6757,6 +6745,7 @@ mk_function(INSTRUCTION *fi, INSTRUCTION *def) /* remove params from symbol table */ remove_params(thisfunc); + current_comment_type = 0; return fi; } @@ -58,6 +58,8 @@ static int load_library(INSTRUCTION *file); static void next_sourcefile(void); static char *tokexpand(void); static bool is_deferred_variable(const char *name); +static void split_comment(void); +static void append_comment(INSTRUCTION *ip); #define instruction(t) bcalloc(t, 1, 0) @@ -87,7 +89,6 @@ static void check_funcs(void); static ssize_t read_one_line(int fd, void *buffer, size_t count); static int one_line_close(int fd); -static void split_comment(void); static bool want_source = false; static bool want_regexp = false; /* lexical scanning kludge */ @@ -148,8 +149,6 @@ static INSTRUCTION *ip_endfile; static INSTRUCTION *ip_beginfile; static INSTRUCTION *comment = NULL; -static INSTRUCTION *program_comment = NULL; -static INSTRUCTION *function_comment = NULL; static bool func_first = true; @@ -160,6 +159,12 @@ static inline INSTRUCTION *list_merge(INSTRUCTION *l1, INSTRUCTION *l2); extern double fmod(double x, double y); +/* first and last pointers to comment list */ +INSTRUCTION *first_comment = NULL; +INSTRUCTION *last_comment = NULL; +/* comment type (program=0, function=1) */ +int current_comment_type = 0; + #define YYSTYPE INSTRUCTION * %} @@ -295,20 +300,12 @@ pattern : /* empty */ { rule = Rule; - if (comment != NULL) { - $$ = list_create(comment); - comment = NULL; - } else - $$ = NULL; + $$ = NULL; } | exp { rule = Rule; - if (comment != NULL) { - $$ = list_prepend($1, comment); - comment = NULL; - } else - $$ = $1; + $$ = $1; } | exp ',' opt_nls exp @@ -383,10 +380,16 @@ action : l_brace statements r_brace opt_semi opt_nls { INSTRUCTION *ip; + INSTRUCTION *tp; if ($2 == NULL) ip = list_create(instruction(Op_no_op)); - else - ip = $2; + else { + if (do_pretty_print) { + tp = bcalloc(Op_no_op, 1, lastline); + ip = list_append($2, tp); + } else + ip = $2; + } $$ = ip; } ; @@ -421,14 +424,10 @@ function_prologue * than one such comments, treat the last as a function * comment. */ - if (comment != NULL && func_first - && strstr(comment->memory->stptr, "\n\n") != NULL) + current_comment_type = 1; + if (last_comment != NULL && func_first + && strstr(last_comment->comment_text->stptr, "\n\n") != NULL) split_comment(); - /* save any other pre-function comment as function comment */ - if (comment != NULL) { - function_comment = comment; - comment = NULL; - } func_first = false; $1->source_file = source; if (install_function($2->lextok, $1, $4) < 0) @@ -488,34 +487,17 @@ a_slash statements : /* empty */ { - if (comment != NULL) { - $$ = list_create(comment); - comment = NULL; - } else $$ = NULL; + $$ = NULL; } | statements statement { if ($2 == NULL) { - if (comment == NULL) - $$ = $1; - else { - $$ = list_append($1, comment); - comment = NULL; - } + $$ = $1; } else { add_lint($2, LINT_no_effect); if ($1 == NULL) { - if (comment == NULL) - $$ = $2; - else { - $$ = list_append($2, comment); - comment = NULL; - } + $$ = $2; } else { - if (comment != NULL) { - list_append($2, comment); - comment = NULL; - } $$ = list_merge($1, $2); } } @@ -2282,13 +2264,6 @@ mk_program() cp = end_block; else cp = list_merge(begin_block, end_block); - /* - * We don't need to clear the comment variables - * since they're not used anymore after this - * function is called. - */ - if (comment != NULL) - (void) list_append(cp, comment); (void) list_append(cp, ip_atexit); (void) list_append(cp, instruction(Op_stop)); @@ -2321,12 +2296,6 @@ mk_program() if (begin_block != NULL) cp = list_merge(begin_block, cp); - if (program_comment != NULL) { - (void) list_prepend(cp, program_comment); - } - if (comment != NULL) { - (void) list_append(cp, comment); - } (void) list_append(cp, ip_atexit); (void) list_append(cp, instruction(Op_stop)); @@ -2976,11 +2945,10 @@ pushback(void) (! lexeof && lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr); } - /* get_comment --- collect comment text */ int -get_comment(void) +get_comment(int flag) { int c; int sl; @@ -2992,6 +2960,12 @@ get_comment(void) while ((c = nextc(false)) != '\n' && c != END_FILE) { tokadd(c); } + if (flag == 1) { + /* comment at end of line. */ + if (c == '\n') + tokadd(c); + break; + } if (c == '\n') { tokadd(c); sourceline++; @@ -3006,6 +2980,7 @@ get_comment(void) break; else if (c != '#') { pushback(); + sourceline--; break; } else tokadd(c); @@ -3013,8 +2988,10 @@ get_comment(void) break; } comment = bcalloc(Op_comment, 1, sl); + comment->comment_text = make_str_node(tokstart, tok - tokstart, 0); comment->source_file = source; - comment->memory = make_str_node(tokstart, tok - tokstart, 0); + comment->comment_text->comment_type = current_comment_type; + append_comment(comment); return c; } @@ -3028,20 +3005,19 @@ split_comment(void) int l; NODE *n; - p = comment->memory->stptr; - l = comment->memory->stlen - 3; + p = last_comment->comment_text->stptr; + l = last_comment->comment_text->stlen - 3; /* have at least two comments so split at last blank line (\n\n) */ while (l >= 0) { if (p[l] == '\n' && p[l+1] == '\n') { - function_comment = comment; - n = function_comment->memory; - function_comment->memory = make_str_node(p + l + 2, n->stlen - l - 2, 0); - /* create program comment */ - program_comment = bcalloc(Op_comment, 1, sourceline); - program_comment->source_file = comment->source_file; + n = last_comment->comment_text; + /* create function comment */ + comment = bcalloc(Op_comment, 1, sourceline); + comment->source_file = source; + comment->comment_text = make_str_node(p + l + 2, n->stlen - l - 2, 0); p[l + 2] = 0; - program_comment->memory = make_str_node(p, l + 2, 0); - comment = NULL; + last_comment->comment_text = make_str_node(p, l + 2, 0); + append_comment(comment); freenode(n); break; } @@ -3050,6 +3026,22 @@ split_comment(void) } } +/* append_comment --- append latest comment to our list of comments */ + +static void +append_comment(INSTRUCTION *ip) +{ + if (first_comment == NULL) { + first_comment = ip; + last_comment = ip; + } else + last_comment->nexti = ip; + + last_comment = ip; + last_comment->nexti = NULL; + ip = NULL; +} + /* allow_newline --- allow newline after &&, ||, ? and : */ static void @@ -3066,7 +3058,7 @@ allow_newline(void) if (c == '#') { if (do_pretty_print && ! do_profile) { /* collect comment byte code iff doing pretty print but not profiling. */ - c = get_comment(); + c = get_comment(1); } else { while ((c = nextc(false)) != '\n' && c != END_FILE) continue; @@ -3278,7 +3270,10 @@ retry: * Collect comment byte code iff doing pretty print * but not profiling. */ - c = get_comment(); + if (lasttok == NEWLINE) + c = get_comment(2); + else + c = get_comment(1); if (c == END_FILE) return lasttok = NEWLINE_EOF; @@ -3315,7 +3310,7 @@ retry: _("use of `\\ #...' line continuation is not portable")); } if (do_pretty_print && ! do_profile) - c = get_comment(); + c = get_comment(2); else { while ((c = nextc(false)) != '\n') if (c == END_FILE) @@ -4333,6 +4328,7 @@ void dump_funcs() { NODE **funcs; + current_comment_type = 1; funcs = function_list(true); (void) foreach_func(funcs, (int (*)(INSTRUCTION *, void *)) pp_func, (void *) 0); efree(funcs); @@ -4385,14 +4381,6 @@ mk_function(INSTRUCTION *fi, INSTRUCTION *def) (t + 1)->tail_call = true; } - /* add any pre-function comment to start of action for profile.c */ - - if (function_comment != NULL) { - function_comment->source_line = 0; - (void) list_prepend(def, function_comment); - function_comment = NULL; - } - /* add an implicit return at end; * also used by 'return' command in debugger */ @@ -4419,6 +4407,7 @@ mk_function(INSTRUCTION *fi, INSTRUCTION *def) /* remove params from symbol table */ remove_params(thisfunc); + current_comment_type = 0; return fi; } @@ -71,6 +71,7 @@ static void save_argv(int, char **); extern int debug_prog(INSTRUCTION *pc); /* debug.c */ extern int init_debug(); /* debug.c */ +extern void print_extra_comments(char *src, int ct); /* These nodes store all the special variables AWK uses */ NODE *ARGC_node, *ARGIND_node, *ARGV_node, *BINMODE_node, *CONVFMT_node; @@ -493,7 +494,9 @@ main(int argc, char **argv) if (do_pretty_print) { dump_prog(code_block); + print_extra_comments(source, 0); dump_funcs(); + print_extra_comments(source, 1); } if (do_dump_vars) @@ -26,6 +26,7 @@ #include "awk.h" static void pprint(INSTRUCTION *startp, INSTRUCTION *endp, bool in_for_header); +static void end_line(INSTRUCTION *ip); static void pp_parenthesize(NODE *n); static void parenthesize(int type, NODE *left, NODE *right); static char *pp_list(int nargs, const char *paren, const char *delim); @@ -36,8 +37,9 @@ static bool is_scalar(int type); static int prec_level(int type); static void pp_push(int type, char *s, int flag); static NODE *pp_pop(void); -static void pprint(INSTRUCTION *startp, INSTRUCTION *endp, bool in_for_header); -static void print_comment(INSTRUCTION *pc, long in); +static void print_comment(INSTRUCTION *ip); +void print_extra_comments(char *src, int ct); + const char *redir2str(int redirtype); #define pp_str vname @@ -57,7 +59,11 @@ static NODE *func_params; /* function parameters */ static FILE *prof_fp; /* where to send the profile */ static long indent_level = 0; +static int lind; +extern INSTRUCTION *first_comment; +extern INSTRUCTION *last_comment; +extern int current_comment_type; #define SPACEOVER 0 @@ -180,48 +186,82 @@ pprint(INSTRUCTION *startp, INSTRUCTION *endp, bool in_for_header) NODE *m; char *tmp; int rule; - long lind; + INSTRUCTION *this_comment; + INSTRUCTION *line_comment; static int rule_count[MAXRULE]; for (pc = startp; pc != endp; pc = pc->nexti) { + if (pc->opcode == Op_rule) { + if (pc->source_file != source) { + print_extra_comments(source, current_comment_type); + } + source = pc->source_file; + } if (pc->source_line > 0) sourceline = pc->source_line; + /* check for last real instruction */ + if ( (pc->nexti != NULL + && pc->nexti->opcode == Op_no_op + && pc->nexti->source_line > 0) + || (pc->opcode == Op_no_op && pc->source_line > 0)) + lind = 1; + else + lind = 0; + + /* + * Scan the comments list for entries relevant to the + * current instruction. + */ + line_comment = NULL; + if (pc->source_line > 0) { + for (this_comment = first_comment; + this_comment != NULL && pc->source_line > 0; + this_comment = this_comment->nexti) { + if (this_comment->comment_text->comment_type == current_comment_type + && this_comment->source_file == source) { + if (this_comment->source_line <= sourceline) { + if (this_comment->source_line == sourceline) { + line_comment = this_comment; + break; + } else { + print_comment(this_comment); + line_comment = NULL; + if (lind == 0) + indent(0); + } + } + } + } + } switch (pc->opcode) { case Op_rule: + /* + * Rules are three instructions long. See append_rule in awkgram.y. + * The first has the Rule Op Code, nexti etc. + * The second, (pc + 1) has firsti and lasti: + * the first/last ACTION instructions for this rule. + * The third (pc + 2) has first_line and last_line: + * the first and last source line numbers. + */ source = pc->source_file; rule = pc->in_rule; if (rule != Rule) { ip = (pc + 1)->firsti; - /* print pre-begin/end comments */ - if (ip->opcode == Op_comment) { - print_comment(ip, 0); - ip = ip->nexti; - } - if (do_profile) { if (! rule_count[rule]++) fprintf(prof_fp, _("\t# %s rule(s)\n\n"), ruletab[rule]); indent(0); } - fprintf(prof_fp, "%s {\n", ruletab[rule]); + fprintf(prof_fp, "%s {", ruletab[rule]); + end_line(line_comment); } else { if (do_profile && ! rule_count[rule]++) fprintf(prof_fp, _("\t# Rule(s)\n\n")); ip = pc->nexti; - lind = ip->exec_count; - /* print pre-block comments */ - if (ip->opcode == Op_exec_count && ip->nexti->opcode == Op_comment) - ip = ip->nexti; - if (ip->opcode == Op_comment) { - print_comment(ip, lind); - if (ip->nexti->nexti == (pc + 1)->firsti) - ip = ip->nexti->nexti; - } if (ip != (pc + 1)->firsti) { /* non-empty pattern */ - indent(lind); pprint(ip->nexti, (pc + 1)->firsti, false); t1 = pp_pop(); fprintf(prof_fp, "%s {", t1->pp_str); @@ -231,9 +271,10 @@ pprint(INSTRUCTION *startp, INSTRUCTION *endp, bool in_for_header) if (do_profile && ip->exec_count > 0) fprintf(prof_fp, " # %ld", ip->exec_count); - fprintf(prof_fp, "\n"); + end_line(line_comment); } else { - fprintf(prof_fp, "{\n"); + fprintf(prof_fp, "{"); + end_line(line_comment); ip = (pc + 1)->firsti; } ip = ip->nexti; @@ -243,6 +284,15 @@ pprint(INSTRUCTION *startp, INSTRUCTION *endp, bool in_for_header) indent_out(); if (do_profile) indent(0); + /* print extra block comments */ + for (this_comment = first_comment; + this_comment != NULL; + this_comment = this_comment->nexti) { + if (this_comment->comment_text->comment_type == current_comment_type + && this_comment->source_file == source + && this_comment->source_line < sourceline) + print_comment(this_comment); + } fprintf(prof_fp, "}\n\n"); pc = (pc + 1)->lasti; break; @@ -328,7 +378,7 @@ cleanup: pp_free(t2); pp_free(t1); if (! in_for_header) - fprintf(prof_fp, "\n"); + end_line(line_comment); break; default: @@ -454,7 +504,7 @@ cleanup: pp_free(t2); pp_free(t1); if (! in_for_header) - fprintf(prof_fp, "\n"); + end_line(line_comment); break; case Op_concat: @@ -475,7 +525,7 @@ cleanup: } else fprintf(prof_fp, "%s %s", op2str(Op_K_delete), array); if (! in_for_header) - fprintf(prof_fp, "\n"); + end_line(line_comment); pp_free(t1); } break; @@ -587,7 +637,7 @@ cleanup: fprintf(prof_fp, "%s%s", op2str(pc->opcode), tmp); efree(tmp); if (! in_for_header) - fprintf(prof_fp, "\n"); + end_line(line_comment); break; case Op_push_re: @@ -688,7 +738,8 @@ cleanup: case Op_K_break: case Op_K_nextfile: case Op_K_next: - fprintf(prof_fp, "%s\n", op2str(pc->opcode)); + fprintf(prof_fp, "%s", op2str(pc->opcode)); + end_line(line_comment); break; case Op_K_return: @@ -696,8 +747,11 @@ cleanup: t1 = pp_pop(); if (is_binary(t1->type)) pp_parenthesize(t1); - if (pc->source_line > 0) /* don't print implicit 'return' at end of function */ - fprintf(prof_fp, "%s %s\n", op2str(pc->opcode), t1->pp_str); + if (pc->source_line > 0) { + /* don't print implicit 'return' at end of function */ + fprintf(prof_fp, "%s %s", op2str(pc->opcode), t1->pp_str); + end_line(line_comment); + } pp_free(t1); break; @@ -705,7 +759,7 @@ cleanup: t1 = pp_pop(); fprintf(prof_fp, "%s", t1->pp_str); if (! in_for_header) - fprintf(prof_fp, "\n"); + end_line(line_comment); pp_free(t1); break; @@ -832,10 +886,12 @@ cleanup: indent(pc->stmt_start->exec_count); if (pc->opcode == Op_K_case) { t1 = pp_pop(); - fprintf(prof_fp, "%s %s:\n", op2str(pc->opcode), t1->pp_str); + fprintf(prof_fp, "%s %s:", op2str(pc->opcode), t1->pp_str); + end_line(line_comment); pp_free(t1); } else - fprintf(prof_fp, "%s:\n", op2str(pc->opcode)); + fprintf(prof_fp, "%s:", op2str(pc->opcode)); + end_line(line_comment); indent_in(); pprint(pc->stmt_start->nexti, pc->stmt_end->nexti, false); indent_out(); @@ -851,14 +907,15 @@ cleanup: ip = pc->branch_if; if (ip->exec_count > 0) fprintf(prof_fp, " # %ld", ip->exec_count); - fprintf(prof_fp, "\n"); + end_line(line_comment); indent_in(); pprint(ip->nexti, pc->branch_else, false); indent_out(); pc = pc->branch_else; if (pc->nexti->opcode == Op_no_op) { indent(SPACEOVER); - fprintf(prof_fp, "}\n"); + fprintf(prof_fp, "}"); + end_line(line_comment); } break; @@ -868,7 +925,8 @@ cleanup: pprint(pc->nexti, pc->branch_end, false); indent_out(); indent(SPACEOVER); - fprintf(prof_fp, "}\n"); + fprintf(prof_fp, "}"); + end_line(line_comment); pc = pc->branch_end; break; @@ -907,10 +965,6 @@ cleanup: indent(pc->exec_count); break; - case Op_comment: - print_comment(pc, 0); - break; - case Op_list: break; @@ -923,6 +977,22 @@ cleanup: } } +/* end pretty print line with new line or on-line comment */ + +void +end_line(INSTRUCTION *ip) +{ + if (ip == NULL || ip->comment_text->comment_type < 0) + fprintf(prof_fp, "\n"); + else { + fprintf(prof_fp, "\t"); + print_comment(ip); + ip = NULL; + if (lind == 0) + indent(0); + } +} + /* pp_string_fp --- printy print a string to the fp */ /* @@ -996,28 +1066,38 @@ print_lib_list(FILE *prof_fp) fprintf(prof_fp, "\n"); } -/* print_comment --- print comment text with proper indentation */ +/* print_extra_comments --- print any left over comments for the current source file and comment type */ + +void +print_extra_comments(char *src, int ct) +{ + INSTRUCTION *ip; + + for (ip = first_comment; ip != NULL; ip = ip->nexti) { + if (ip->comment_text->comment_type == current_comment_type + && ip->source_file == src) { + print_comment(ip); + } + } +} + +/* print_comment --- print comment text */ static void -print_comment(INSTRUCTION* pc, long in) +print_comment(INSTRUCTION *ip) { char *text; size_t count; - bool after_newline = false; - count = pc->memory->stlen; - text = pc->memory->stptr; + count = ip->comment_text->stlen; + text = ip->comment_text->stptr; - indent(in); /* is this correct? Where should comments go? */ for (; count > 0; count--, text++) { - if (after_newline) { - indent(in); - after_newline = false; - } putc(*text, prof_fp); - if (*text == '\n') - after_newline = true; + if (*text == '\n' && count > 1) + indent(0); } + ip->comment_text->comment_type = -1; /* turn off printed comment */ } /* dump_prog --- dump the program */ @@ -1037,6 +1117,7 @@ dump_prog(INSTRUCTION *code) if (do_profile) fprintf(prof_fp, _("\t# gawk profile, created %s\n"), ctime(& now)); print_lib_list(prof_fp); + current_comment_type = 0; /* program */ pprint(code, NULL, false); } @@ -1582,14 +1663,9 @@ pp_func(INSTRUCTION *pc, void *data ATTRIBUTE_UNUSED) fp = pc->nexti->nexti; func = pc->func_body; + source = pc->source_file; fprintf(prof_fp, "\n"); - /* print any function comment */ - if (fp->opcode == Op_comment && fp->source_line == 0) { - print_comment(fp, 0); - fp = fp->nexti; - } - indent(pc->nexti->exec_count); fprintf(prof_fp, "%s %s(", op2str(Op_K_function), func->vname); pcount = func->param_cnt; |