diff options
-rw-r--r-- | ChangeLog | 107 | ||||
-rw-r--r-- | awk.h | 2 | ||||
-rw-r--r-- | awkgram.c | 721 | ||||
-rw-r--r-- | awkgram.y | 3 | ||||
-rw-r--r-- | configh.in | 6 | ||||
-rwxr-xr-x | configure | 5 | ||||
-rw-r--r-- | configure.ac | 5 | ||||
-rw-r--r-- | eval.c | 4 | ||||
-rw-r--r-- | extension/ChangeLog | 149 | ||||
-rw-r--r-- | extension/testext.c | 60 | ||||
-rw-r--r-- | gawkapi.c | 92 | ||||
-rw-r--r-- | gawkapi.h | 38 | ||||
-rw-r--r-- | io.c | 155 | ||||
-rw-r--r-- | test/ChangeLog | 4 | ||||
-rw-r--r-- | test/testext.ok | 6 |
15 files changed, 962 insertions, 395 deletions
@@ -124,6 +124,36 @@ and a it's a Node_val set to Nnull_string, return AWK_UNDEFINED instead of AWK_NUMBER 0. +2014-11-06 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * awk.h (redirect_string): First argument should be const. Add a new + extfd argument to enable extensions to create files with pre-opened + file descriptors. + (after_beginfile): Declare function used in both eval.c and gawkapi.c. + * eval.c (after_beginfile): Remove extern declaration now in awk.h. + * gawkapi.c (api_get_file): Implement API changes to return + awk_input_buf_t and/or awk_output_buf_t info, as well as accept an + fd for inserting an opened file into the table. + * gawkapi.h (gawk_api): Modify the api_get_file declaration to + return awk_bool_t and add 3 new arguments -- a file descriptor + for inserting an already opened file, and awk_input_buf_t and + awk_output_buf_t to return info about both input and output. + (get_file): Add new arguments to the macro. + * io.c (redirect_string): First arg should be const, and add a new + extfd arg so extensions can pass in a file that has already been + opened by the extension. Use the passed-in fd when appropriate, + and pass it into two_way_open. + (redirect): Pass new fd -1 arg to redirect_string. + (two_way_open): Accept new extension fd parameter and open it + as a socket. + +2014-11-05 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * io.c (retryable): New function to indicate whether I/O can be + retried for this file instead of throwing a hard error. + (get_a_record) Check whether this file is configured for retryable + I/O before returning nonstandard -2. + 2014-11-03 Norihiro Tanaka <noritnk@kcn.ne.jp> * re.c (research): Use dfa superset to improve matching speed. @@ -1292,6 +1322,45 @@ * io.c (get_a_record): Change `min' to `MIN' for consistency with other files and general practice. +2013-07-07 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * configure.ac (AC_CHECK_FUNCS): Check for sigprocmask. + * io.c (wait_any): If sigprocmask is available, block signals instead + of ignoring them temporarily. + +2013-07-05 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * gawkapi.h (gawk_api): Document that the api_get_file function will not + access the file type and length arguments if the file name is empty. + +2013-07-04 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * configure.ac (AC_CHECK_FUNCS): Add a check for waitpid. + * io.c (wait_any): Enhance comment to explain why we loop reaping all + exited children when the argument is zero. When available, use waitpid + with WNOHANG to avoid blocking. Remove my previous incorrect patch to + exit after reaping the first child. The function is intended to + wait for all children, since we are not careful about reaping children + as soon as they die. + +2013-07-02 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * gawkapi.h (gawk_api): Remove unused api_lookup_file hook. + (lookup_file): Remove associated macro. + * gawkapi.c (api_lookup_file): Remove unused function. + (api_impl): Remove unused api_lookup_file hook. + +2013-07-02 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * awkgram.y (main_beginfile): Declare new global INSTRUCTION *. + (parse_program): Set main_beginfile to point to the BEGINFILE + instruction block. + * gawkapi.c (api_get_file): After nextfile starts a new file, + we need to run the BEGINFILE actions. We retrieve the + instruction pointer from main_beginfile and execute it until + we reach the Op_after_beginfile opcode. We then run after_beginfile + manually and restore the value of currule and source. + 2013-07-04 Andrew J. Schorr <aschorr@telemetry-investments.com> * gawkapi.h (awk_element_t): Add comment indicating that the array @@ -1302,6 +1371,44 @@ force_string redundant, since node_to_awk_value does that internally when we request a string. +2013-07-02 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * eval.c (update_ERRNO_string): Set PROCINFO["errno"] to 0. + * io.c (inrec): Since get_a_record may now return -2, be sure + to throw an error in that case as well. + (wait_any): Fix what appears to be a bug. The old logic repeatedly + called wait until it failed. When a process has multiple children, + this causes it to stall until all of them have exited. Instead, + we now exit the function after the first successful wait call. + (do_getline_redir, do_getline): Handle case where get_a_record + returns -2. + (errno_io_retry): New function to decide whether an I/O operation should + be retried. + (get_a_record): When read returns an error, call errno_io_retry to + decide whether the operation should be retried. If so, return -2 + instead of setting the IOP_AT_EOF flag. + +2013-07-01 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * eval.c (update_ERRNO_int, unset_ERRNO): Update PROCINFO["errno"]. + +2013-06-30 Andrew J. Schorr <aschorr@telemetry-investments.com> + * awk.h (redirect_string): Declare new function that provides API access + to the redirection mechanism. + * gawkapi.h (GAWK_API_MINOR_VERSION): Bump from 0 to 1 since 2 new + hooks were added to the api. + (gawk_api_t): Add 2 new functions api_lookup_file and api_get_file. + (lookup_file, get_file): New macros to wrap the new API functions. + * gawkapi.c (curfile): Declare this extern, since it is needed + by lookup_file and get_flie. + (api_lookup_file): Find an open file using curfile or getredirect(). + (api_get_file): Find or open a file using curfile or redirect_string(). + (api_impl): Add api_lookup_file and api_get_file. + * io.c (redirect_string): Renamed from redirect and changed arguments + to take a string instead of a 'NODE *'. This allows it to be called + through the API's new get_file hook. + (redirect): Now implemented by calling redirect_string backend function. + 2013-07-04 Arnold D. Robbins <arnold@skeeve.com> * builtin.c (format_tree): Fixes for %c with multibyte characters @@ -1484,6 +1484,7 @@ extern void set_FNR(void); extern void set_NR(void); extern struct redirect *redirect(NODE *redir_exp, int redirtype, int *errflg); +extern struct redirect *redirect_string(const char *redir_exp_str, size_t redir_exp_len, int not_string_flag, int redirtype, int *errflg, int extfd); extern NODE *do_close(int nargs); extern int flush_io(void); extern int close_io(bool *stdio_problem); @@ -1502,6 +1503,7 @@ extern int is_off_limits_var(const char *var); extern char *estrdup(const char *str, size_t len); extern void update_global_values(); extern long getenv_long(const char *name); +extern void after_beginfile(IOBUF **curfile); /* mpfr.c */ extern void set_PREC(void); @@ -187,6 +187,7 @@ static INSTRUCTION *ip_atexit = NULL; static INSTRUCTION *ip_end; static INSTRUCTION *ip_endfile; static INSTRUCTION *ip_beginfile; +INSTRUCTION *main_beginfile; static INSTRUCTION *comment = NULL; static INSTRUCTION *program_comment = NULL; @@ -205,7 +206,7 @@ extern double fmod(double x, double y); #define YYSTYPE INSTRUCTION * -#line 209 "awkgram.c" /* yacc.c:339 */ +#line 210 "awkgram.c" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus @@ -359,7 +360,7 @@ int yyparse (void); /* Copy the second part of user declarations. */ -#line 363 "awkgram.c" /* yacc.c:358 */ +#line 364 "awkgram.c" /* yacc.c:358 */ #ifdef short # undef short @@ -661,25 +662,25 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 208, 208, 210, 215, 216, 222, 234, 238, 249, - 255, 260, 268, 276, 278, 283, 291, 293, 299, 307, - 317, 347, 361, 375, 383, 394, 406, 408, 410, 416, - 421, 422, 426, 461, 460, 494, 496, 501, 507, 535, - 540, 541, 545, 547, 549, 556, 646, 688, 730, 843, - 850, 857, 867, 876, 885, 894, 905, 921, 920, 944, - 956, 956, 1054, 1054, 1087, 1117, 1123, 1124, 1130, 1131, - 1138, 1143, 1155, 1169, 1171, 1179, 1184, 1186, 1194, 1196, - 1205, 1206, 1214, 1219, 1219, 1230, 1234, 1242, 1243, 1246, - 1248, 1253, 1254, 1263, 1264, 1269, 1274, 1280, 1282, 1284, - 1291, 1292, 1298, 1299, 1304, 1306, 1311, 1313, 1321, 1326, - 1335, 1342, 1344, 1346, 1362, 1372, 1379, 1381, 1386, 1388, - 1390, 1398, 1400, 1405, 1407, 1412, 1414, 1416, 1466, 1468, - 1470, 1472, 1474, 1476, 1478, 1480, 1494, 1499, 1504, 1529, - 1535, 1537, 1539, 1541, 1543, 1545, 1550, 1554, 1586, 1588, - 1594, 1600, 1613, 1614, 1615, 1620, 1625, 1629, 1633, 1648, - 1661, 1666, 1702, 1720, 1721, 1727, 1728, 1733, 1735, 1742, - 1759, 1776, 1778, 1785, 1790, 1798, 1808, 1820, 1829, 1833, - 1837, 1841, 1845, 1849, 1852, 1854, 1858, 1862, 1866 + 0, 209, 209, 211, 216, 217, 223, 235, 239, 250, + 256, 261, 269, 277, 279, 284, 292, 294, 300, 308, + 318, 348, 362, 376, 384, 395, 407, 409, 411, 417, + 422, 423, 427, 462, 461, 495, 497, 502, 508, 536, + 541, 542, 546, 548, 550, 557, 647, 689, 731, 844, + 851, 858, 868, 877, 886, 895, 906, 922, 921, 945, + 957, 957, 1055, 1055, 1088, 1118, 1124, 1125, 1131, 1132, + 1139, 1144, 1156, 1170, 1172, 1180, 1185, 1187, 1195, 1197, + 1206, 1207, 1215, 1220, 1220, 1231, 1235, 1243, 1244, 1247, + 1249, 1254, 1255, 1264, 1265, 1270, 1275, 1281, 1283, 1285, + 1292, 1293, 1299, 1300, 1305, 1307, 1312, 1314, 1322, 1327, + 1336, 1343, 1345, 1347, 1363, 1373, 1380, 1382, 1387, 1389, + 1391, 1399, 1401, 1406, 1408, 1413, 1415, 1417, 1467, 1469, + 1471, 1473, 1475, 1477, 1479, 1481, 1495, 1500, 1505, 1530, + 1536, 1538, 1540, 1542, 1544, 1546, 1551, 1555, 1587, 1589, + 1595, 1601, 1614, 1615, 1616, 1621, 1626, 1630, 1634, 1649, + 1662, 1667, 1703, 1721, 1722, 1728, 1729, 1734, 1736, 1743, + 1760, 1777, 1779, 1786, 1791, 1799, 1809, 1821, 1830, 1834, + 1838, 1842, 1846, 1850, 1853, 1855, 1859, 1863, 1867 }; #endif @@ -1852,26 +1853,26 @@ yyreduce: switch (yyn) { case 3: -#line 211 "awkgram.y" /* yacc.c:1646 */ +#line 212 "awkgram.y" /* yacc.c:1646 */ { rule = 0; yyerrok; } -#line 1861 "awkgram.c" /* yacc.c:1646 */ +#line 1862 "awkgram.c" /* yacc.c:1646 */ break; case 5: -#line 217 "awkgram.y" /* yacc.c:1646 */ +#line 218 "awkgram.y" /* yacc.c:1646 */ { next_sourcefile(); if (sourcefile == srcfiles) process_deferred(); } -#line 1871 "awkgram.c" /* yacc.c:1646 */ +#line 1872 "awkgram.c" /* yacc.c:1646 */ break; case 6: -#line 223 "awkgram.y" /* yacc.c:1646 */ +#line 224 "awkgram.y" /* yacc.c:1646 */ { rule = 0; /* @@ -1880,19 +1881,19 @@ yyreduce: */ /* yyerrok; */ } -#line 1884 "awkgram.c" /* yacc.c:1646 */ +#line 1885 "awkgram.c" /* yacc.c:1646 */ break; case 7: -#line 235 "awkgram.y" /* yacc.c:1646 */ +#line 236 "awkgram.y" /* yacc.c:1646 */ { (void) append_rule((yyvsp[-1]), (yyvsp[0])); } -#line 1892 "awkgram.c" /* yacc.c:1646 */ +#line 1893 "awkgram.c" /* yacc.c:1646 */ break; case 8: -#line 239 "awkgram.y" /* yacc.c:1646 */ +#line 240 "awkgram.y" /* yacc.c:1646 */ { if (rule != Rule) { msg(_("%s blocks must have an action part"), ruletab[rule]); @@ -1903,39 +1904,39 @@ yyreduce: } else /* pattern rule with non-empty pattern */ (void) append_rule((yyvsp[-1]), NULL); } -#line 1907 "awkgram.c" /* yacc.c:1646 */ +#line 1908 "awkgram.c" /* yacc.c:1646 */ break; case 9: -#line 250 "awkgram.y" /* yacc.c:1646 */ +#line 251 "awkgram.y" /* yacc.c:1646 */ { in_function = NULL; (void) mk_function((yyvsp[-1]), (yyvsp[0])); yyerrok; } -#line 1917 "awkgram.c" /* yacc.c:1646 */ +#line 1918 "awkgram.c" /* yacc.c:1646 */ break; case 10: -#line 256 "awkgram.y" /* yacc.c:1646 */ +#line 257 "awkgram.y" /* yacc.c:1646 */ { want_source = false; yyerrok; } -#line 1926 "awkgram.c" /* yacc.c:1646 */ +#line 1927 "awkgram.c" /* yacc.c:1646 */ break; case 11: -#line 261 "awkgram.y" /* yacc.c:1646 */ +#line 262 "awkgram.y" /* yacc.c:1646 */ { want_source = false; yyerrok; } -#line 1935 "awkgram.c" /* yacc.c:1646 */ +#line 1936 "awkgram.c" /* yacc.c:1646 */ break; case 12: -#line 269 "awkgram.y" /* yacc.c:1646 */ +#line 270 "awkgram.y" /* yacc.c:1646 */ { if (include_source((yyvsp[0])) < 0) YYABORT; @@ -1943,23 +1944,23 @@ yyreduce: bcfree((yyvsp[0])); (yyval) = NULL; } -#line 1947 "awkgram.c" /* yacc.c:1646 */ +#line 1948 "awkgram.c" /* yacc.c:1646 */ break; case 13: -#line 277 "awkgram.y" /* yacc.c:1646 */ +#line 278 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1953 "awkgram.c" /* yacc.c:1646 */ +#line 1954 "awkgram.c" /* yacc.c:1646 */ break; case 14: -#line 279 "awkgram.y" /* yacc.c:1646 */ +#line 280 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1959 "awkgram.c" /* yacc.c:1646 */ +#line 1960 "awkgram.c" /* yacc.c:1646 */ break; case 15: -#line 284 "awkgram.y" /* yacc.c:1646 */ +#line 285 "awkgram.y" /* yacc.c:1646 */ { if (load_library((yyvsp[0])) < 0) YYABORT; @@ -1967,23 +1968,23 @@ yyreduce: bcfree((yyvsp[0])); (yyval) = NULL; } -#line 1971 "awkgram.c" /* yacc.c:1646 */ +#line 1972 "awkgram.c" /* yacc.c:1646 */ break; case 16: -#line 292 "awkgram.y" /* yacc.c:1646 */ +#line 293 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1977 "awkgram.c" /* yacc.c:1646 */ +#line 1978 "awkgram.c" /* yacc.c:1646 */ break; case 17: -#line 294 "awkgram.y" /* yacc.c:1646 */ +#line 295 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 1983 "awkgram.c" /* yacc.c:1646 */ +#line 1984 "awkgram.c" /* yacc.c:1646 */ break; case 18: -#line 299 "awkgram.y" /* yacc.c:1646 */ +#line 300 "awkgram.y" /* yacc.c:1646 */ { rule = Rule; if (comment != NULL) { @@ -1992,11 +1993,11 @@ yyreduce: } else (yyval) = NULL; } -#line 1996 "awkgram.c" /* yacc.c:1646 */ +#line 1997 "awkgram.c" /* yacc.c:1646 */ break; case 19: -#line 308 "awkgram.y" /* yacc.c:1646 */ +#line 309 "awkgram.y" /* yacc.c:1646 */ { rule = Rule; if (comment != NULL) { @@ -2005,11 +2006,11 @@ yyreduce: } else (yyval) = (yyvsp[0]); } -#line 2009 "awkgram.c" /* yacc.c:1646 */ +#line 2010 "awkgram.c" /* yacc.c:1646 */ break; case 20: -#line 318 "awkgram.y" /* yacc.c:1646 */ +#line 319 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *tp; @@ -2039,11 +2040,11 @@ yyreduce: (yyval) = list_append(list_merge((yyvsp[-3]), (yyvsp[0])), tp); rule = Rule; } -#line 2043 "awkgram.c" /* yacc.c:1646 */ +#line 2044 "awkgram.c" /* yacc.c:1646 */ break; case 21: -#line 348 "awkgram.y" /* yacc.c:1646 */ +#line 349 "awkgram.y" /* yacc.c:1646 */ { static int begin_seen = 0; @@ -2057,11 +2058,11 @@ yyreduce: check_comment(); (yyval) = (yyvsp[0]); } -#line 2061 "awkgram.c" /* yacc.c:1646 */ +#line 2062 "awkgram.c" /* yacc.c:1646 */ break; case 22: -#line 362 "awkgram.y" /* yacc.c:1646 */ +#line 363 "awkgram.y" /* yacc.c:1646 */ { static int end_seen = 0; @@ -2075,11 +2076,11 @@ yyreduce: check_comment(); (yyval) = (yyvsp[0]); } -#line 2079 "awkgram.c" /* yacc.c:1646 */ +#line 2080 "awkgram.c" /* yacc.c:1646 */ break; case 23: -#line 376 "awkgram.y" /* yacc.c:1646 */ +#line 377 "awkgram.y" /* yacc.c:1646 */ { func_first = false; (yyvsp[0])->in_rule = rule = BEGINFILE; @@ -2087,11 +2088,11 @@ yyreduce: check_comment(); (yyval) = (yyvsp[0]); } -#line 2091 "awkgram.c" /* yacc.c:1646 */ +#line 2092 "awkgram.c" /* yacc.c:1646 */ break; case 24: -#line 384 "awkgram.y" /* yacc.c:1646 */ +#line 385 "awkgram.y" /* yacc.c:1646 */ { func_first = false; (yyvsp[0])->in_rule = rule = ENDFILE; @@ -2099,11 +2100,11 @@ yyreduce: check_comment(); (yyval) = (yyvsp[0]); } -#line 2103 "awkgram.c" /* yacc.c:1646 */ +#line 2104 "awkgram.c" /* yacc.c:1646 */ break; case 25: -#line 395 "awkgram.y" /* yacc.c:1646 */ +#line 396 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *ip; if ((yyvsp[-3]) == NULL) @@ -2112,39 +2113,39 @@ yyreduce: ip = (yyvsp[-3]); (yyval) = ip; } -#line 2116 "awkgram.c" /* yacc.c:1646 */ +#line 2117 "awkgram.c" /* yacc.c:1646 */ break; case 26: -#line 407 "awkgram.y" /* yacc.c:1646 */ +#line 408 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2122 "awkgram.c" /* yacc.c:1646 */ +#line 2123 "awkgram.c" /* yacc.c:1646 */ break; case 27: -#line 409 "awkgram.y" /* yacc.c:1646 */ +#line 410 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2128 "awkgram.c" /* yacc.c:1646 */ +#line 2129 "awkgram.c" /* yacc.c:1646 */ break; case 28: -#line 411 "awkgram.y" /* yacc.c:1646 */ +#line 412 "awkgram.y" /* yacc.c:1646 */ { yyerror(_("`%s' is a built-in function, it cannot be redefined"), tokstart); YYABORT; } -#line 2138 "awkgram.c" /* yacc.c:1646 */ +#line 2139 "awkgram.c" /* yacc.c:1646 */ break; case 29: -#line 417 "awkgram.y" /* yacc.c:1646 */ +#line 418 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2144 "awkgram.c" /* yacc.c:1646 */ +#line 2145 "awkgram.c" /* yacc.c:1646 */ break; case 32: -#line 427 "awkgram.y" /* yacc.c:1646 */ +#line 428 "awkgram.y" /* yacc.c:1646 */ { /* * treat any comments between BOF and the first function @@ -2171,17 +2172,17 @@ yyreduce: /* $4 already free'd in install_function */ (yyval) = (yyvsp[-5]); } -#line 2175 "awkgram.c" /* yacc.c:1646 */ +#line 2176 "awkgram.c" /* yacc.c:1646 */ break; case 33: -#line 461 "awkgram.y" /* yacc.c:1646 */ +#line 462 "awkgram.y" /* yacc.c:1646 */ { want_regexp = true; } -#line 2181 "awkgram.c" /* yacc.c:1646 */ +#line 2182 "awkgram.c" /* yacc.c:1646 */ break; case 34: -#line 463 "awkgram.y" /* yacc.c:1646 */ +#line 464 "awkgram.y" /* yacc.c:1646 */ { NODE *n, *exp; char *re; @@ -2210,28 +2211,28 @@ yyreduce: (yyval)->opcode = Op_match_rec; (yyval)->memory = n; } -#line 2214 "awkgram.c" /* yacc.c:1646 */ +#line 2215 "awkgram.c" /* yacc.c:1646 */ break; case 35: -#line 495 "awkgram.y" /* yacc.c:1646 */ +#line 496 "awkgram.y" /* yacc.c:1646 */ { bcfree((yyvsp[0])); } -#line 2220 "awkgram.c" /* yacc.c:1646 */ +#line 2221 "awkgram.c" /* yacc.c:1646 */ break; case 37: -#line 501 "awkgram.y" /* yacc.c:1646 */ +#line 502 "awkgram.y" /* yacc.c:1646 */ { if (comment != NULL) { (yyval) = list_create(comment); comment = NULL; } else (yyval) = NULL; } -#line 2231 "awkgram.c" /* yacc.c:1646 */ +#line 2232 "awkgram.c" /* yacc.c:1646 */ break; case 38: -#line 508 "awkgram.y" /* yacc.c:1646 */ +#line 509 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[0]) == NULL) { if (comment == NULL) @@ -2259,40 +2260,40 @@ yyreduce: } yyerrok; } -#line 2263 "awkgram.c" /* yacc.c:1646 */ +#line 2264 "awkgram.c" /* yacc.c:1646 */ break; case 39: -#line 536 "awkgram.y" /* yacc.c:1646 */ +#line 537 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2269 "awkgram.c" /* yacc.c:1646 */ +#line 2270 "awkgram.c" /* yacc.c:1646 */ break; case 42: -#line 546 "awkgram.y" /* yacc.c:1646 */ +#line 547 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2275 "awkgram.c" /* yacc.c:1646 */ +#line 2276 "awkgram.c" /* yacc.c:1646 */ break; case 43: -#line 548 "awkgram.y" /* yacc.c:1646 */ +#line 549 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 2281 "awkgram.c" /* yacc.c:1646 */ +#line 2282 "awkgram.c" /* yacc.c:1646 */ break; case 44: -#line 550 "awkgram.y" /* yacc.c:1646 */ +#line 551 "awkgram.y" /* yacc.c:1646 */ { if (do_pretty_print) (yyval) = list_prepend((yyvsp[0]), instruction(Op_exec_count)); else (yyval) = (yyvsp[0]); } -#line 2292 "awkgram.c" /* yacc.c:1646 */ +#line 2293 "awkgram.c" /* yacc.c:1646 */ break; case 45: -#line 557 "awkgram.y" /* yacc.c:1646 */ +#line 558 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *dflt, *curr = NULL, *cexp, *cstmt; INSTRUCTION *ip, *nextc, *tbreak; @@ -2382,11 +2383,11 @@ yyreduce: break_allowed--; fix_break_continue(ip, tbreak, NULL); } -#line 2386 "awkgram.c" /* yacc.c:1646 */ +#line 2387 "awkgram.c" /* yacc.c:1646 */ break; case 46: -#line 647 "awkgram.y" /* yacc.c:1646 */ +#line 648 "awkgram.y" /* yacc.c:1646 */ { /* * ----------------- @@ -2428,11 +2429,11 @@ yyreduce: continue_allowed--; fix_break_continue(ip, tbreak, tcont); } -#line 2432 "awkgram.c" /* yacc.c:1646 */ +#line 2433 "awkgram.c" /* yacc.c:1646 */ break; case 47: -#line 689 "awkgram.y" /* yacc.c:1646 */ +#line 690 "awkgram.y" /* yacc.c:1646 */ { /* * ----------------- @@ -2474,11 +2475,11 @@ yyreduce: } /* else $1 and $4 are NULLs */ } -#line 2478 "awkgram.c" /* yacc.c:1646 */ +#line 2479 "awkgram.c" /* yacc.c:1646 */ break; case 48: -#line 731 "awkgram.y" /* yacc.c:1646 */ +#line 732 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *ip; char *var_name = (yyvsp[-5])->lextok; @@ -2591,44 +2592,44 @@ regular_loop: break_allowed--; continue_allowed--; } -#line 2595 "awkgram.c" /* yacc.c:1646 */ +#line 2596 "awkgram.c" /* yacc.c:1646 */ break; case 49: -#line 844 "awkgram.y" /* yacc.c:1646 */ +#line 845 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_for_loop((yyvsp[-11]), (yyvsp[-9]), (yyvsp[-6]), (yyvsp[-3]), (yyvsp[0])); break_allowed--; continue_allowed--; } -#line 2606 "awkgram.c" /* yacc.c:1646 */ +#line 2607 "awkgram.c" /* yacc.c:1646 */ break; case 50: -#line 851 "awkgram.y" /* yacc.c:1646 */ +#line 852 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_for_loop((yyvsp[-10]), (yyvsp[-8]), (INSTRUCTION *) NULL, (yyvsp[-3]), (yyvsp[0])); break_allowed--; continue_allowed--; } -#line 2617 "awkgram.c" /* yacc.c:1646 */ +#line 2618 "awkgram.c" /* yacc.c:1646 */ break; case 51: -#line 858 "awkgram.y" /* yacc.c:1646 */ +#line 859 "awkgram.y" /* yacc.c:1646 */ { if (do_pretty_print) (yyval) = list_prepend((yyvsp[0]), instruction(Op_exec_count)); else (yyval) = (yyvsp[0]); } -#line 2628 "awkgram.c" /* yacc.c:1646 */ +#line 2629 "awkgram.c" /* yacc.c:1646 */ break; case 52: -#line 868 "awkgram.y" /* yacc.c:1646 */ +#line 869 "awkgram.y" /* yacc.c:1646 */ { if (! break_allowed) error_ln((yyvsp[-1])->source_line, @@ -2637,11 +2638,11 @@ regular_loop: (yyval) = list_create((yyvsp[-1])); } -#line 2641 "awkgram.c" /* yacc.c:1646 */ +#line 2642 "awkgram.c" /* yacc.c:1646 */ break; case 53: -#line 877 "awkgram.y" /* yacc.c:1646 */ +#line 878 "awkgram.y" /* yacc.c:1646 */ { if (! continue_allowed) error_ln((yyvsp[-1])->source_line, @@ -2650,11 +2651,11 @@ regular_loop: (yyval) = list_create((yyvsp[-1])); } -#line 2654 "awkgram.c" /* yacc.c:1646 */ +#line 2655 "awkgram.c" /* yacc.c:1646 */ break; case 54: -#line 886 "awkgram.y" /* yacc.c:1646 */ +#line 887 "awkgram.y" /* yacc.c:1646 */ { /* if inside function (rule = 0), resolve context at run-time */ if (rule && rule != Rule) @@ -2663,11 +2664,11 @@ regular_loop: (yyvsp[-1])->target_jmp = ip_rec; (yyval) = list_create((yyvsp[-1])); } -#line 2667 "awkgram.c" /* yacc.c:1646 */ +#line 2668 "awkgram.c" /* yacc.c:1646 */ break; case 55: -#line 895 "awkgram.y" /* yacc.c:1646 */ +#line 896 "awkgram.y" /* yacc.c:1646 */ { /* if inside function (rule = 0), resolve context at run-time */ if (rule == BEGIN || rule == END || rule == ENDFILE) @@ -2678,11 +2679,11 @@ regular_loop: (yyvsp[-1])->target_endfile = ip_endfile; (yyval) = list_create((yyvsp[-1])); } -#line 2682 "awkgram.c" /* yacc.c:1646 */ +#line 2683 "awkgram.c" /* yacc.c:1646 */ break; case 56: -#line 906 "awkgram.y" /* yacc.c:1646 */ +#line 907 "awkgram.y" /* yacc.c:1646 */ { /* Initialize the two possible jump targets, the actual target * is resolved at run-time. @@ -2697,20 +2698,20 @@ regular_loop: } else (yyval) = list_append((yyvsp[-1]), (yyvsp[-2])); } -#line 2701 "awkgram.c" /* yacc.c:1646 */ +#line 2702 "awkgram.c" /* yacc.c:1646 */ break; case 57: -#line 921 "awkgram.y" /* yacc.c:1646 */ +#line 922 "awkgram.y" /* yacc.c:1646 */ { if (! in_function) yyerror(_("`return' used outside function context")); } -#line 2710 "awkgram.c" /* yacc.c:1646 */ +#line 2711 "awkgram.c" /* yacc.c:1646 */ break; case 58: -#line 924 "awkgram.y" /* yacc.c:1646 */ +#line 925 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-1]) == NULL) { (yyval) = list_create((yyvsp[-3])); @@ -2731,17 +2732,17 @@ regular_loop: (yyval) = list_append((yyvsp[-1]), (yyvsp[-3])); } } -#line 2735 "awkgram.c" /* yacc.c:1646 */ +#line 2736 "awkgram.c" /* yacc.c:1646 */ break; case 60: -#line 956 "awkgram.y" /* yacc.c:1646 */ +#line 957 "awkgram.y" /* yacc.c:1646 */ { in_print = true; in_parens = 0; } -#line 2741 "awkgram.c" /* yacc.c:1646 */ +#line 2742 "awkgram.c" /* yacc.c:1646 */ break; case 61: -#line 957 "awkgram.y" /* yacc.c:1646 */ +#line 958 "awkgram.y" /* yacc.c:1646 */ { /* * Optimization: plain `print' has no expression list, so $3 is null. @@ -2838,17 +2839,17 @@ regular_print: } } } -#line 2842 "awkgram.c" /* yacc.c:1646 */ +#line 2843 "awkgram.c" /* yacc.c:1646 */ break; case 62: -#line 1054 "awkgram.y" /* yacc.c:1646 */ +#line 1055 "awkgram.y" /* yacc.c:1646 */ { sub_counter = 0; } -#line 2848 "awkgram.c" /* yacc.c:1646 */ +#line 2849 "awkgram.c" /* yacc.c:1646 */ break; case 63: -#line 1055 "awkgram.y" /* yacc.c:1646 */ +#line 1056 "awkgram.y" /* yacc.c:1646 */ { char *arr = (yyvsp[-2])->lextok; @@ -2881,11 +2882,11 @@ regular_print: (yyval) = list_append(list_append((yyvsp[0]), (yyvsp[-2])), (yyvsp[-3])); } } -#line 2885 "awkgram.c" /* yacc.c:1646 */ +#line 2886 "awkgram.c" /* yacc.c:1646 */ break; case 64: -#line 1092 "awkgram.y" /* yacc.c:1646 */ +#line 1093 "awkgram.y" /* yacc.c:1646 */ { static bool warned = false; char *arr = (yyvsp[-1])->lextok; @@ -2911,52 +2912,52 @@ regular_print: fatal(_("`delete' is not allowed with FUNCTAB")); } } -#line 2915 "awkgram.c" /* yacc.c:1646 */ +#line 2916 "awkgram.c" /* yacc.c:1646 */ break; case 65: -#line 1118 "awkgram.y" /* yacc.c:1646 */ +#line 1119 "awkgram.y" /* yacc.c:1646 */ { (yyval) = optimize_assignment((yyvsp[0])); } -#line 2921 "awkgram.c" /* yacc.c:1646 */ +#line 2922 "awkgram.c" /* yacc.c:1646 */ break; case 66: -#line 1123 "awkgram.y" /* yacc.c:1646 */ +#line 1124 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2927 "awkgram.c" /* yacc.c:1646 */ +#line 2928 "awkgram.c" /* yacc.c:1646 */ break; case 67: -#line 1125 "awkgram.y" /* yacc.c:1646 */ +#line 1126 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2933 "awkgram.c" /* yacc.c:1646 */ +#line 2934 "awkgram.c" /* yacc.c:1646 */ break; case 68: -#line 1130 "awkgram.y" /* yacc.c:1646 */ +#line 1131 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2939 "awkgram.c" /* yacc.c:1646 */ +#line 2940 "awkgram.c" /* yacc.c:1646 */ break; case 69: -#line 1132 "awkgram.y" /* yacc.c:1646 */ +#line 1133 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-1]) == NULL) (yyval) = list_create((yyvsp[0])); else (yyval) = list_prepend((yyvsp[-1]), (yyvsp[0])); } -#line 2950 "awkgram.c" /* yacc.c:1646 */ +#line 2951 "awkgram.c" /* yacc.c:1646 */ break; case 70: -#line 1139 "awkgram.y" /* yacc.c:1646 */ +#line 1140 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 2956 "awkgram.c" /* yacc.c:1646 */ +#line 2957 "awkgram.c" /* yacc.c:1646 */ break; case 71: -#line 1144 "awkgram.y" /* yacc.c:1646 */ +#line 1145 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *casestmt = (yyvsp[0]); if ((yyvsp[0]) == NULL) @@ -2968,11 +2969,11 @@ regular_print: bcfree((yyvsp[-2])); (yyval) = (yyvsp[-4]); } -#line 2972 "awkgram.c" /* yacc.c:1646 */ +#line 2973 "awkgram.c" /* yacc.c:1646 */ break; case 72: -#line 1156 "awkgram.y" /* yacc.c:1646 */ +#line 1157 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *casestmt = (yyvsp[0]); if ((yyvsp[0]) == NULL) @@ -2983,17 +2984,17 @@ regular_print: (yyvsp[-3])->case_stmt = casestmt; (yyval) = (yyvsp[-3]); } -#line 2987 "awkgram.c" /* yacc.c:1646 */ +#line 2988 "awkgram.c" /* yacc.c:1646 */ break; case 73: -#line 1170 "awkgram.y" /* yacc.c:1646 */ +#line 1171 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 2993 "awkgram.c" /* yacc.c:1646 */ +#line 2994 "awkgram.c" /* yacc.c:1646 */ break; case 74: -#line 1172 "awkgram.y" /* yacc.c:1646 */ +#line 1173 "awkgram.y" /* yacc.c:1646 */ { NODE *n = (yyvsp[0])->memory; (void) force_number(n); @@ -3001,71 +3002,71 @@ regular_print: bcfree((yyvsp[-1])); (yyval) = (yyvsp[0]); } -#line 3005 "awkgram.c" /* yacc.c:1646 */ +#line 3006 "awkgram.c" /* yacc.c:1646 */ break; case 75: -#line 1180 "awkgram.y" /* yacc.c:1646 */ +#line 1181 "awkgram.y" /* yacc.c:1646 */ { bcfree((yyvsp[-1])); (yyval) = (yyvsp[0]); } -#line 3014 "awkgram.c" /* yacc.c:1646 */ +#line 3015 "awkgram.c" /* yacc.c:1646 */ break; case 76: -#line 1185 "awkgram.y" /* yacc.c:1646 */ +#line 1186 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3020 "awkgram.c" /* yacc.c:1646 */ +#line 3021 "awkgram.c" /* yacc.c:1646 */ break; case 77: -#line 1187 "awkgram.y" /* yacc.c:1646 */ +#line 1188 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_push_re; (yyval) = (yyvsp[0]); } -#line 3029 "awkgram.c" /* yacc.c:1646 */ +#line 3030 "awkgram.c" /* yacc.c:1646 */ break; case 78: -#line 1195 "awkgram.y" /* yacc.c:1646 */ +#line 1196 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3035 "awkgram.c" /* yacc.c:1646 */ +#line 3036 "awkgram.c" /* yacc.c:1646 */ break; case 79: -#line 1197 "awkgram.y" /* yacc.c:1646 */ +#line 1198 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3041 "awkgram.c" /* yacc.c:1646 */ +#line 3042 "awkgram.c" /* yacc.c:1646 */ break; case 81: -#line 1207 "awkgram.y" /* yacc.c:1646 */ +#line 1208 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3049 "awkgram.c" /* yacc.c:1646 */ +#line 3050 "awkgram.c" /* yacc.c:1646 */ break; case 82: -#line 1214 "awkgram.y" /* yacc.c:1646 */ +#line 1215 "awkgram.y" /* yacc.c:1646 */ { in_print = false; in_parens = 0; (yyval) = NULL; } -#line 3059 "awkgram.c" /* yacc.c:1646 */ +#line 3060 "awkgram.c" /* yacc.c:1646 */ break; case 83: -#line 1219 "awkgram.y" /* yacc.c:1646 */ +#line 1220 "awkgram.y" /* yacc.c:1646 */ { in_print = false; in_parens = 0; } -#line 3065 "awkgram.c" /* yacc.c:1646 */ +#line 3066 "awkgram.c" /* yacc.c:1646 */ break; case 84: -#line 1220 "awkgram.y" /* yacc.c:1646 */ +#line 1221 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-2])->redir_type == redirect_twoway && (yyvsp[0])->lasti->opcode == Op_K_getline_redir @@ -3073,136 +3074,136 @@ regular_print: yyerror(_("multistage two-way pipelines don't work")); (yyval) = list_prepend((yyvsp[0]), (yyvsp[-2])); } -#line 3077 "awkgram.c" /* yacc.c:1646 */ +#line 3078 "awkgram.c" /* yacc.c:1646 */ break; case 85: -#line 1231 "awkgram.y" /* yacc.c:1646 */ +#line 1232 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_condition((yyvsp[-3]), (yyvsp[-5]), (yyvsp[0]), NULL, NULL); } -#line 3085 "awkgram.c" /* yacc.c:1646 */ +#line 3086 "awkgram.c" /* yacc.c:1646 */ break; case 86: -#line 1236 "awkgram.y" /* yacc.c:1646 */ +#line 1237 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_condition((yyvsp[-6]), (yyvsp[-8]), (yyvsp[-3]), (yyvsp[-2]), (yyvsp[0])); } -#line 3093 "awkgram.c" /* yacc.c:1646 */ +#line 3094 "awkgram.c" /* yacc.c:1646 */ break; case 91: -#line 1253 "awkgram.y" /* yacc.c:1646 */ +#line 1254 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3099 "awkgram.c" /* yacc.c:1646 */ +#line 3100 "awkgram.c" /* yacc.c:1646 */ break; case 92: -#line 1255 "awkgram.y" /* yacc.c:1646 */ +#line 1256 "awkgram.y" /* yacc.c:1646 */ { bcfree((yyvsp[-1])); (yyval) = (yyvsp[0]); } -#line 3108 "awkgram.c" /* yacc.c:1646 */ +#line 3109 "awkgram.c" /* yacc.c:1646 */ break; case 93: -#line 1263 "awkgram.y" /* yacc.c:1646 */ +#line 1264 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3114 "awkgram.c" /* yacc.c:1646 */ +#line 3115 "awkgram.c" /* yacc.c:1646 */ break; case 94: -#line 1265 "awkgram.y" /* yacc.c:1646 */ +#line 1266 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3120 "awkgram.c" /* yacc.c:1646 */ +#line 3121 "awkgram.c" /* yacc.c:1646 */ break; case 95: -#line 1270 "awkgram.y" /* yacc.c:1646 */ +#line 1271 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->param_count = 0; (yyval) = list_create((yyvsp[0])); } -#line 3129 "awkgram.c" /* yacc.c:1646 */ +#line 3130 "awkgram.c" /* yacc.c:1646 */ break; case 96: -#line 1275 "awkgram.y" /* yacc.c:1646 */ +#line 1276 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->param_count = (yyvsp[-2])->lasti->param_count + 1; (yyval) = list_append((yyvsp[-2]), (yyvsp[0])); yyerrok; } -#line 3139 "awkgram.c" /* yacc.c:1646 */ +#line 3140 "awkgram.c" /* yacc.c:1646 */ break; case 97: -#line 1281 "awkgram.y" /* yacc.c:1646 */ +#line 1282 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3145 "awkgram.c" /* yacc.c:1646 */ +#line 3146 "awkgram.c" /* yacc.c:1646 */ break; case 98: -#line 1283 "awkgram.y" /* yacc.c:1646 */ +#line 1284 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3151 "awkgram.c" /* yacc.c:1646 */ +#line 3152 "awkgram.c" /* yacc.c:1646 */ break; case 99: -#line 1285 "awkgram.y" /* yacc.c:1646 */ +#line 1286 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-2]); } -#line 3157 "awkgram.c" /* yacc.c:1646 */ +#line 3158 "awkgram.c" /* yacc.c:1646 */ break; case 100: -#line 1291 "awkgram.y" /* yacc.c:1646 */ +#line 1292 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3163 "awkgram.c" /* yacc.c:1646 */ +#line 3164 "awkgram.c" /* yacc.c:1646 */ break; case 101: -#line 1293 "awkgram.y" /* yacc.c:1646 */ +#line 1294 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3169 "awkgram.c" /* yacc.c:1646 */ +#line 3170 "awkgram.c" /* yacc.c:1646 */ break; case 102: -#line 1298 "awkgram.y" /* yacc.c:1646 */ +#line 1299 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3175 "awkgram.c" /* yacc.c:1646 */ +#line 3176 "awkgram.c" /* yacc.c:1646 */ break; case 103: -#line 1300 "awkgram.y" /* yacc.c:1646 */ +#line 1301 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3181 "awkgram.c" /* yacc.c:1646 */ +#line 3182 "awkgram.c" /* yacc.c:1646 */ break; case 104: -#line 1305 "awkgram.y" /* yacc.c:1646 */ +#line 1306 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_expression_list(NULL, (yyvsp[0])); } -#line 3187 "awkgram.c" /* yacc.c:1646 */ +#line 3188 "awkgram.c" /* yacc.c:1646 */ break; case 105: -#line 1307 "awkgram.y" /* yacc.c:1646 */ +#line 1308 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0])); yyerrok; } -#line 3196 "awkgram.c" /* yacc.c:1646 */ +#line 3197 "awkgram.c" /* yacc.c:1646 */ break; case 106: -#line 1312 "awkgram.y" /* yacc.c:1646 */ +#line 1313 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3202 "awkgram.c" /* yacc.c:1646 */ +#line 3203 "awkgram.c" /* yacc.c:1646 */ break; case 107: -#line 1314 "awkgram.y" /* yacc.c:1646 */ +#line 1315 "awkgram.y" /* yacc.c:1646 */ { /* * Returning the expression list instead of NULL lets @@ -3210,52 +3211,52 @@ regular_print: */ (yyval) = (yyvsp[-1]); } -#line 3214 "awkgram.c" /* yacc.c:1646 */ +#line 3215 "awkgram.c" /* yacc.c:1646 */ break; case 108: -#line 1322 "awkgram.y" /* yacc.c:1646 */ +#line 1323 "awkgram.y" /* yacc.c:1646 */ { /* Ditto */ (yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0])); } -#line 3223 "awkgram.c" /* yacc.c:1646 */ +#line 3224 "awkgram.c" /* yacc.c:1646 */ break; case 109: -#line 1327 "awkgram.y" /* yacc.c:1646 */ +#line 1328 "awkgram.y" /* yacc.c:1646 */ { /* Ditto */ (yyval) = (yyvsp[-2]); } -#line 3232 "awkgram.c" /* yacc.c:1646 */ +#line 3233 "awkgram.c" /* yacc.c:1646 */ break; case 110: -#line 1336 "awkgram.y" /* yacc.c:1646 */ +#line 1337 "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 3243 "awkgram.c" /* yacc.c:1646 */ +#line 3244 "awkgram.c" /* yacc.c:1646 */ break; case 111: -#line 1343 "awkgram.y" /* yacc.c:1646 */ +#line 1344 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3249 "awkgram.c" /* yacc.c:1646 */ +#line 3250 "awkgram.c" /* yacc.c:1646 */ break; case 112: -#line 1345 "awkgram.y" /* yacc.c:1646 */ +#line 1346 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3255 "awkgram.c" /* yacc.c:1646 */ +#line 3256 "awkgram.c" /* yacc.c:1646 */ break; case 113: -#line 1347 "awkgram.y" /* yacc.c:1646 */ +#line 1348 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[-2])->lasti->opcode == Op_match_rec) warning_ln((yyvsp[-1])->source_line, @@ -3271,11 +3272,11 @@ regular_print: (yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1])); } } -#line 3275 "awkgram.c" /* yacc.c:1646 */ +#line 3276 "awkgram.c" /* yacc.c:1646 */ break; case 114: -#line 1363 "awkgram.y" /* yacc.c:1646 */ +#line 1364 "awkgram.y" /* yacc.c:1646 */ { if (do_lint_old) warning_ln((yyvsp[-1])->source_line, @@ -3285,91 +3286,91 @@ regular_print: (yyvsp[-1])->expr_count = 1; (yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1])); } -#line 3289 "awkgram.c" /* yacc.c:1646 */ +#line 3290 "awkgram.c" /* yacc.c:1646 */ break; case 115: -#line 1373 "awkgram.y" /* yacc.c:1646 */ +#line 1374 "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 3300 "awkgram.c" /* yacc.c:1646 */ +#line 3301 "awkgram.c" /* yacc.c:1646 */ break; case 116: -#line 1380 "awkgram.y" /* yacc.c:1646 */ +#line 1381 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_condition((yyvsp[-4]), (yyvsp[-3]), (yyvsp[-2]), (yyvsp[-1]), (yyvsp[0])); } -#line 3306 "awkgram.c" /* yacc.c:1646 */ +#line 3307 "awkgram.c" /* yacc.c:1646 */ break; case 117: -#line 1382 "awkgram.y" /* yacc.c:1646 */ +#line 1383 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3312 "awkgram.c" /* yacc.c:1646 */ +#line 3313 "awkgram.c" /* yacc.c:1646 */ break; case 118: -#line 1387 "awkgram.y" /* yacc.c:1646 */ +#line 1388 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3318 "awkgram.c" /* yacc.c:1646 */ +#line 3319 "awkgram.c" /* yacc.c:1646 */ break; case 119: -#line 1389 "awkgram.y" /* yacc.c:1646 */ +#line 1390 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3324 "awkgram.c" /* yacc.c:1646 */ +#line 3325 "awkgram.c" /* yacc.c:1646 */ break; case 120: -#line 1391 "awkgram.y" /* yacc.c:1646 */ +#line 1392 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_assign_quotient; (yyval) = (yyvsp[0]); } -#line 3333 "awkgram.c" /* yacc.c:1646 */ +#line 3334 "awkgram.c" /* yacc.c:1646 */ break; case 121: -#line 1399 "awkgram.y" /* yacc.c:1646 */ +#line 1400 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3339 "awkgram.c" /* yacc.c:1646 */ +#line 3340 "awkgram.c" /* yacc.c:1646 */ break; case 122: -#line 1401 "awkgram.y" /* yacc.c:1646 */ +#line 1402 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3345 "awkgram.c" /* yacc.c:1646 */ +#line 3346 "awkgram.c" /* yacc.c:1646 */ break; case 123: -#line 1406 "awkgram.y" /* yacc.c:1646 */ +#line 1407 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3351 "awkgram.c" /* yacc.c:1646 */ +#line 3352 "awkgram.c" /* yacc.c:1646 */ break; case 124: -#line 1408 "awkgram.y" /* yacc.c:1646 */ +#line 1409 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3357 "awkgram.c" /* yacc.c:1646 */ +#line 3358 "awkgram.c" /* yacc.c:1646 */ break; case 125: -#line 1413 "awkgram.y" /* yacc.c:1646 */ +#line 1414 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3363 "awkgram.c" /* yacc.c:1646 */ +#line 3364 "awkgram.c" /* yacc.c:1646 */ break; case 126: -#line 1415 "awkgram.y" /* yacc.c:1646 */ +#line 1416 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3369 "awkgram.c" /* yacc.c:1646 */ +#line 3370 "awkgram.c" /* yacc.c:1646 */ break; case 127: -#line 1417 "awkgram.y" /* yacc.c:1646 */ +#line 1418 "awkgram.y" /* yacc.c:1646 */ { int count = 2; bool is_simple_var = false; @@ -3416,47 +3417,47 @@ regular_print: max_args = count; } } -#line 3420 "awkgram.c" /* yacc.c:1646 */ +#line 3421 "awkgram.c" /* yacc.c:1646 */ break; case 129: -#line 1469 "awkgram.y" /* yacc.c:1646 */ +#line 1470 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3426 "awkgram.c" /* yacc.c:1646 */ +#line 3427 "awkgram.c" /* yacc.c:1646 */ break; case 130: -#line 1471 "awkgram.y" /* yacc.c:1646 */ +#line 1472 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3432 "awkgram.c" /* yacc.c:1646 */ +#line 3433 "awkgram.c" /* yacc.c:1646 */ break; case 131: -#line 1473 "awkgram.y" /* yacc.c:1646 */ +#line 1474 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3438 "awkgram.c" /* yacc.c:1646 */ +#line 3439 "awkgram.c" /* yacc.c:1646 */ break; case 132: -#line 1475 "awkgram.y" /* yacc.c:1646 */ +#line 1476 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3444 "awkgram.c" /* yacc.c:1646 */ +#line 3445 "awkgram.c" /* yacc.c:1646 */ break; case 133: -#line 1477 "awkgram.y" /* yacc.c:1646 */ +#line 1478 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3450 "awkgram.c" /* yacc.c:1646 */ +#line 3451 "awkgram.c" /* yacc.c:1646 */ break; case 134: -#line 1479 "awkgram.y" /* yacc.c:1646 */ +#line 1480 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3456 "awkgram.c" /* yacc.c:1646 */ +#line 3457 "awkgram.c" /* yacc.c:1646 */ break; case 135: -#line 1481 "awkgram.y" /* yacc.c:1646 */ +#line 1482 "awkgram.y" /* yacc.c:1646 */ { /* * In BEGINFILE/ENDFILE, allow `getline [var] < file' @@ -3470,29 +3471,29 @@ regular_print: _("non-redirected `getline' undefined inside END action")); (yyval) = mk_getline((yyvsp[-2]), (yyvsp[-1]), (yyvsp[0]), redirect_input); } -#line 3474 "awkgram.c" /* yacc.c:1646 */ +#line 3475 "awkgram.c" /* yacc.c:1646 */ break; case 136: -#line 1495 "awkgram.y" /* yacc.c:1646 */ +#line 1496 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postincrement; (yyval) = mk_assignment((yyvsp[-1]), NULL, (yyvsp[0])); } -#line 3483 "awkgram.c" /* yacc.c:1646 */ +#line 3484 "awkgram.c" /* yacc.c:1646 */ break; case 137: -#line 1500 "awkgram.y" /* yacc.c:1646 */ +#line 1501 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postdecrement; (yyval) = mk_assignment((yyvsp[-1]), NULL, (yyvsp[0])); } -#line 3492 "awkgram.c" /* yacc.c:1646 */ +#line 3493 "awkgram.c" /* yacc.c:1646 */ break; case 138: -#line 1505 "awkgram.y" /* yacc.c:1646 */ +#line 1506 "awkgram.y" /* yacc.c:1646 */ { if (do_lint_old) { warning_ln((yyvsp[-1])->source_line, @@ -3512,64 +3513,64 @@ regular_print: (yyval) = list_append(list_merge(t, (yyvsp[0])), (yyvsp[-1])); } } -#line 3516 "awkgram.c" /* yacc.c:1646 */ +#line 3517 "awkgram.c" /* yacc.c:1646 */ break; case 139: -#line 1530 "awkgram.y" /* yacc.c:1646 */ +#line 1531 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_getline((yyvsp[-1]), (yyvsp[0]), (yyvsp[-3]), (yyvsp[-2])->redir_type); bcfree((yyvsp[-2])); } -#line 3525 "awkgram.c" /* yacc.c:1646 */ +#line 3526 "awkgram.c" /* yacc.c:1646 */ break; case 140: -#line 1536 "awkgram.y" /* yacc.c:1646 */ +#line 1537 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3531 "awkgram.c" /* yacc.c:1646 */ +#line 3532 "awkgram.c" /* yacc.c:1646 */ break; case 141: -#line 1538 "awkgram.y" /* yacc.c:1646 */ +#line 1539 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3537 "awkgram.c" /* yacc.c:1646 */ +#line 3538 "awkgram.c" /* yacc.c:1646 */ break; case 142: -#line 1540 "awkgram.y" /* yacc.c:1646 */ +#line 1541 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3543 "awkgram.c" /* yacc.c:1646 */ +#line 3544 "awkgram.c" /* yacc.c:1646 */ break; case 143: -#line 1542 "awkgram.y" /* yacc.c:1646 */ +#line 1543 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3549 "awkgram.c" /* yacc.c:1646 */ +#line 3550 "awkgram.c" /* yacc.c:1646 */ break; case 144: -#line 1544 "awkgram.y" /* yacc.c:1646 */ +#line 1545 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3555 "awkgram.c" /* yacc.c:1646 */ +#line 3556 "awkgram.c" /* yacc.c:1646 */ break; case 145: -#line 1546 "awkgram.y" /* yacc.c:1646 */ +#line 1547 "awkgram.y" /* yacc.c:1646 */ { (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); } -#line 3561 "awkgram.c" /* yacc.c:1646 */ +#line 3562 "awkgram.c" /* yacc.c:1646 */ break; case 146: -#line 1551 "awkgram.y" /* yacc.c:1646 */ +#line 1552 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_create((yyvsp[0])); } -#line 3569 "awkgram.c" /* yacc.c:1646 */ +#line 3570 "awkgram.c" /* yacc.c:1646 */ break; case 147: -#line 1555 "awkgram.y" /* yacc.c:1646 */ +#line 1556 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[0])->opcode == Op_match_rec) { (yyvsp[0])->opcode = Op_nomatch; @@ -3601,37 +3602,37 @@ regular_print: } } } -#line 3605 "awkgram.c" /* yacc.c:1646 */ +#line 3606 "awkgram.c" /* yacc.c:1646 */ break; case 148: -#line 1587 "awkgram.y" /* yacc.c:1646 */ +#line 1588 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3611 "awkgram.c" /* yacc.c:1646 */ +#line 3612 "awkgram.c" /* yacc.c:1646 */ break; case 149: -#line 1589 "awkgram.y" /* yacc.c:1646 */ +#line 1590 "awkgram.y" /* yacc.c:1646 */ { (yyval) = snode((yyvsp[-1]), (yyvsp[-3])); if ((yyval) == NULL) YYABORT; } -#line 3621 "awkgram.c" /* yacc.c:1646 */ +#line 3622 "awkgram.c" /* yacc.c:1646 */ break; case 150: -#line 1595 "awkgram.y" /* yacc.c:1646 */ +#line 1596 "awkgram.y" /* yacc.c:1646 */ { (yyval) = snode((yyvsp[-1]), (yyvsp[-3])); if ((yyval) == NULL) YYABORT; } -#line 3631 "awkgram.c" /* yacc.c:1646 */ +#line 3632 "awkgram.c" /* yacc.c:1646 */ break; case 151: -#line 1601 "awkgram.y" /* yacc.c:1646 */ +#line 1602 "awkgram.y" /* yacc.c:1646 */ { static bool warned = false; @@ -3644,45 +3645,45 @@ regular_print: if ((yyval) == NULL) YYABORT; } -#line 3648 "awkgram.c" /* yacc.c:1646 */ +#line 3649 "awkgram.c" /* yacc.c:1646 */ break; case 154: -#line 1616 "awkgram.y" /* yacc.c:1646 */ +#line 1617 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[-1])->opcode = Op_preincrement; (yyval) = mk_assignment((yyvsp[0]), NULL, (yyvsp[-1])); } -#line 3657 "awkgram.c" /* yacc.c:1646 */ +#line 3658 "awkgram.c" /* yacc.c:1646 */ break; case 155: -#line 1621 "awkgram.y" /* yacc.c:1646 */ +#line 1622 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[-1])->opcode = Op_predecrement; (yyval) = mk_assignment((yyvsp[0]), NULL, (yyvsp[-1])); } -#line 3666 "awkgram.c" /* yacc.c:1646 */ +#line 3667 "awkgram.c" /* yacc.c:1646 */ break; case 156: -#line 1626 "awkgram.y" /* yacc.c:1646 */ +#line 1627 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_create((yyvsp[0])); } -#line 3674 "awkgram.c" /* yacc.c:1646 */ +#line 3675 "awkgram.c" /* yacc.c:1646 */ break; case 157: -#line 1630 "awkgram.y" /* yacc.c:1646 */ +#line 1631 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_create((yyvsp[0])); } -#line 3682 "awkgram.c" /* yacc.c:1646 */ +#line 3683 "awkgram.c" /* yacc.c:1646 */ break; case 158: -#line 1634 "awkgram.y" /* yacc.c:1646 */ +#line 1635 "awkgram.y" /* yacc.c:1646 */ { if ((yyvsp[0])->lasti->opcode == Op_push_i && ((yyvsp[0])->lasti->memory->flags & (STRCUR|STRING)) == 0 @@ -3697,11 +3698,11 @@ regular_print: (yyval) = list_append((yyvsp[0]), (yyvsp[-1])); } } -#line 3701 "awkgram.c" /* yacc.c:1646 */ +#line 3702 "awkgram.c" /* yacc.c:1646 */ break; case 159: -#line 1649 "awkgram.y" /* yacc.c:1646 */ +#line 1650 "awkgram.y" /* yacc.c:1646 */ { /* * was: $$ = $2 @@ -3711,20 +3712,20 @@ regular_print: (yyvsp[-1])->memory = make_number(0.0); (yyval) = list_append((yyvsp[0]), (yyvsp[-1])); } -#line 3715 "awkgram.c" /* yacc.c:1646 */ +#line 3716 "awkgram.c" /* yacc.c:1646 */ break; case 160: -#line 1662 "awkgram.y" /* yacc.c:1646 */ +#line 1663 "awkgram.y" /* yacc.c:1646 */ { func_use((yyvsp[0])->lasti->func_name, FUNC_USE); (yyval) = (yyvsp[0]); } -#line 3724 "awkgram.c" /* yacc.c:1646 */ +#line 3725 "awkgram.c" /* yacc.c:1646 */ break; case 161: -#line 1667 "awkgram.y" /* yacc.c:1646 */ +#line 1668 "awkgram.y" /* yacc.c:1646 */ { /* indirect function call */ INSTRUCTION *f, *t; @@ -3757,11 +3758,11 @@ regular_print: (yyval) = list_prepend((yyvsp[0]), t); } -#line 3761 "awkgram.c" /* yacc.c:1646 */ +#line 3762 "awkgram.c" /* yacc.c:1646 */ break; case 162: -#line 1703 "awkgram.y" /* yacc.c:1646 */ +#line 1704 "awkgram.y" /* yacc.c:1646 */ { param_sanity((yyvsp[-1])); (yyvsp[-3])->opcode = Op_func_call; @@ -3775,49 +3776,49 @@ regular_print: (yyval) = list_append(t, (yyvsp[-3])); } } -#line 3779 "awkgram.c" /* yacc.c:1646 */ +#line 3780 "awkgram.c" /* yacc.c:1646 */ break; case 163: -#line 1720 "awkgram.y" /* yacc.c:1646 */ +#line 1721 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3785 "awkgram.c" /* yacc.c:1646 */ +#line 3786 "awkgram.c" /* yacc.c:1646 */ break; case 164: -#line 1722 "awkgram.y" /* yacc.c:1646 */ +#line 1723 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3791 "awkgram.c" /* yacc.c:1646 */ +#line 3792 "awkgram.c" /* yacc.c:1646 */ break; case 165: -#line 1727 "awkgram.y" /* yacc.c:1646 */ +#line 1728 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3797 "awkgram.c" /* yacc.c:1646 */ +#line 3798 "awkgram.c" /* yacc.c:1646 */ break; case 166: -#line 1729 "awkgram.y" /* yacc.c:1646 */ +#line 1730 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3803 "awkgram.c" /* yacc.c:1646 */ +#line 3804 "awkgram.c" /* yacc.c:1646 */ break; case 167: -#line 1734 "awkgram.y" /* yacc.c:1646 */ +#line 1735 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3809 "awkgram.c" /* yacc.c:1646 */ +#line 3810 "awkgram.c" /* yacc.c:1646 */ break; case 168: -#line 1736 "awkgram.y" /* yacc.c:1646 */ +#line 1737 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_merge((yyvsp[-1]), (yyvsp[0])); } -#line 3817 "awkgram.c" /* yacc.c:1646 */ +#line 3818 "awkgram.c" /* yacc.c:1646 */ break; case 169: -#line 1743 "awkgram.y" /* yacc.c:1646 */ +#line 1744 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *ip = (yyvsp[0])->lasti; int count = ip->sub_count; /* # of SUBSEP-seperated expressions */ @@ -3831,11 +3832,11 @@ regular_print: sub_counter++; /* count # of dimensions */ (yyval) = (yyvsp[0]); } -#line 3835 "awkgram.c" /* yacc.c:1646 */ +#line 3836 "awkgram.c" /* yacc.c:1646 */ break; case 170: -#line 1760 "awkgram.y" /* yacc.c:1646 */ +#line 1761 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *t = (yyvsp[-1]); if ((yyvsp[-1]) == NULL) { @@ -3849,31 +3850,31 @@ regular_print: (yyvsp[0])->sub_count = count_expressions(&t, false); (yyval) = list_append(t, (yyvsp[0])); } -#line 3853 "awkgram.c" /* yacc.c:1646 */ +#line 3854 "awkgram.c" /* yacc.c:1646 */ break; case 171: -#line 1777 "awkgram.y" /* yacc.c:1646 */ +#line 1778 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); } -#line 3859 "awkgram.c" /* yacc.c:1646 */ +#line 3860 "awkgram.c" /* yacc.c:1646 */ break; case 172: -#line 1779 "awkgram.y" /* yacc.c:1646 */ +#line 1780 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_merge((yyvsp[-1]), (yyvsp[0])); } -#line 3867 "awkgram.c" /* yacc.c:1646 */ +#line 3868 "awkgram.c" /* yacc.c:1646 */ break; case 173: -#line 1786 "awkgram.y" /* yacc.c:1646 */ +#line 1787 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[-1]); } -#line 3873 "awkgram.c" /* yacc.c:1646 */ +#line 3874 "awkgram.c" /* yacc.c:1646 */ break; case 174: -#line 1791 "awkgram.y" /* yacc.c:1646 */ +#line 1792 "awkgram.y" /* yacc.c:1646 */ { char *var_name = (yyvsp[0])->lextok; @@ -3881,22 +3882,22 @@ regular_print: (yyvsp[0])->memory = variable((yyvsp[0])->source_line, var_name, Node_var_new); (yyval) = list_create((yyvsp[0])); } -#line 3885 "awkgram.c" /* yacc.c:1646 */ +#line 3886 "awkgram.c" /* yacc.c:1646 */ break; case 175: -#line 1799 "awkgram.y" /* yacc.c:1646 */ +#line 1800 "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 3896 "awkgram.c" /* yacc.c:1646 */ +#line 3897 "awkgram.c" /* yacc.c:1646 */ break; case 176: -#line 1809 "awkgram.y" /* yacc.c:1646 */ +#line 1810 "awkgram.y" /* yacc.c:1646 */ { INSTRUCTION *ip = (yyvsp[0])->nexti; if (ip->opcode == Op_push @@ -3908,73 +3909,73 @@ regular_print: } else (yyval) = (yyvsp[0]); } -#line 3912 "awkgram.c" /* yacc.c:1646 */ +#line 3913 "awkgram.c" /* yacc.c:1646 */ break; case 177: -#line 1821 "awkgram.y" /* yacc.c:1646 */ +#line 1822 "awkgram.y" /* yacc.c:1646 */ { (yyval) = list_append((yyvsp[-1]), (yyvsp[-2])); if ((yyvsp[0]) != NULL) mk_assignment((yyvsp[-1]), NULL, (yyvsp[0])); } -#line 3922 "awkgram.c" /* yacc.c:1646 */ +#line 3923 "awkgram.c" /* yacc.c:1646 */ break; case 178: -#line 1830 "awkgram.y" /* yacc.c:1646 */ +#line 1831 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postincrement; } -#line 3930 "awkgram.c" /* yacc.c:1646 */ +#line 3931 "awkgram.c" /* yacc.c:1646 */ break; case 179: -#line 1834 "awkgram.y" /* yacc.c:1646 */ +#line 1835 "awkgram.y" /* yacc.c:1646 */ { (yyvsp[0])->opcode = Op_postdecrement; } -#line 3938 "awkgram.c" /* yacc.c:1646 */ +#line 3939 "awkgram.c" /* yacc.c:1646 */ break; case 180: -#line 1837 "awkgram.y" /* yacc.c:1646 */ +#line 1838 "awkgram.y" /* yacc.c:1646 */ { (yyval) = NULL; } -#line 3944 "awkgram.c" /* yacc.c:1646 */ +#line 3945 "awkgram.c" /* yacc.c:1646 */ break; case 182: -#line 1845 "awkgram.y" /* yacc.c:1646 */ +#line 1846 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3950 "awkgram.c" /* yacc.c:1646 */ +#line 3951 "awkgram.c" /* yacc.c:1646 */ break; case 183: -#line 1849 "awkgram.y" /* yacc.c:1646 */ +#line 1850 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3956 "awkgram.c" /* yacc.c:1646 */ +#line 3957 "awkgram.c" /* yacc.c:1646 */ break; case 186: -#line 1858 "awkgram.y" /* yacc.c:1646 */ +#line 1859 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3962 "awkgram.c" /* yacc.c:1646 */ +#line 3963 "awkgram.c" /* yacc.c:1646 */ break; case 187: -#line 1862 "awkgram.y" /* yacc.c:1646 */ +#line 1863 "awkgram.y" /* yacc.c:1646 */ { (yyval) = (yyvsp[0]); yyerrok; } -#line 3968 "awkgram.c" /* yacc.c:1646 */ +#line 3969 "awkgram.c" /* yacc.c:1646 */ break; case 188: -#line 1866 "awkgram.y" /* yacc.c:1646 */ +#line 1867 "awkgram.y" /* yacc.c:1646 */ { yyerrok; } -#line 3974 "awkgram.c" /* yacc.c:1646 */ +#line 3975 "awkgram.c" /* yacc.c:1646 */ break; -#line 3978 "awkgram.c" /* yacc.c:1646 */ +#line 3979 "awkgram.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -4202,7 +4203,7 @@ yyreturn: #endif return yyresult; } -#line 1868 "awkgram.y" /* yacc.c:1906 */ +#line 1869 "awkgram.y" /* yacc.c:1906 */ struct token { @@ -4711,7 +4712,7 @@ parse_program(INSTRUCTION **pcode) ip_newfile = ip_rec = ip_atexit = ip_beginfile = ip_endfile = NULL; else { ip_endfile = instruction(Op_no_op); - ip_beginfile = instruction(Op_no_op); + main_beginfile = ip_beginfile = instruction(Op_no_op); ip_rec = instruction(Op_get_record); /* target for `next', also ip_newfile */ ip_newfile = bcalloc(Op_newfile, 2, 0); /* target for `nextfile' */ ip_newfile->target_jmp = ip_end; @@ -147,6 +147,7 @@ static INSTRUCTION *ip_atexit = NULL; static INSTRUCTION *ip_end; static INSTRUCTION *ip_endfile; static INSTRUCTION *ip_beginfile; +INSTRUCTION *main_beginfile; static INSTRUCTION *comment = NULL; static INSTRUCTION *program_comment = NULL; @@ -2373,7 +2374,7 @@ parse_program(INSTRUCTION **pcode) ip_newfile = ip_rec = ip_atexit = ip_beginfile = ip_endfile = NULL; else { ip_endfile = instruction(Op_no_op); - ip_beginfile = instruction(Op_no_op); + main_beginfile = ip_beginfile = instruction(Op_no_op); ip_rec = instruction(Op_get_record); /* target for `next', also ip_newfile */ ip_newfile = bcalloc(Op_newfile, 2, 0); /* target for `nextfile' */ ip_newfile->target_jmp = ip_end; @@ -171,6 +171,9 @@ /* Define to 1 if you have the `setsid' function. */ #undef HAVE_SETSID +/* Define to 1 if you have the `sigprocmask' function. */ +#undef HAVE_SIGPROCMASK + /* Define to 1 if you have the `snprintf' function. */ #undef HAVE_SNPRINTF @@ -296,6 +299,9 @@ /* Define to 1 if you have the `usleep' function. */ #undef HAVE_USLEEP +/* Define to 1 if you have the `waitpid' function. */ +#undef HAVE_WAITPID + /* Define to 1 if you have the <wchar.h> header file. */ #undef HAVE_WCHAR_H @@ -10284,9 +10284,10 @@ esac for ac_func in atexit btowc fmod getgrent getgroups grantpt \ isascii iswctype iswlower iswupper mbrlen \ memcmp memcpy memcpy_ulong memmove memset \ - memset_ulong mkstemp posix_openpt setenv setlocale setsid snprintf strchr \ + memset_ulong mkstemp posix_openpt setenv setlocale setsid sigprocmask \ + snprintf strchr \ strerror strftime strcasecmp strncasecmp strcoll strtod strtoul \ - system tmpfile towlower towupper tzset usleep wcrtomb \ + system tmpfile towlower towupper tzset usleep waitpid wcrtomb \ wcscoll wctype do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` diff --git a/configure.ac b/configure.ac index 0b33b966..7e5f69c3 100644 --- a/configure.ac +++ b/configure.ac @@ -273,9 +273,10 @@ esac AC_CHECK_FUNCS(atexit btowc fmod getgrent getgroups grantpt \ isascii iswctype iswlower iswupper mbrlen \ memcmp memcpy memcpy_ulong memmove memset \ - memset_ulong mkstemp posix_openpt setenv setlocale setsid snprintf strchr \ + memset_ulong mkstemp posix_openpt setenv setlocale setsid sigprocmask \ + snprintf strchr \ strerror strftime strcasecmp strncasecmp strcoll strtod strtoul \ - system tmpfile towlower towupper tzset usleep wcrtomb \ + system tmpfile towlower towupper tzset usleep waitpid wcrtomb \ wcscoll wctype) dnl this check is for both mbrtowc and the mbstate_t type, which is good AC_FUNC_MBRTOWC @@ -25,7 +25,6 @@ #include "awk.h" -extern void after_beginfile(IOBUF **curfile); extern double pow(double x, double y); extern double modf(double x, double *yp); extern double fmod(double x, double y); @@ -1026,6 +1025,7 @@ update_ERRNO_int(int errcode) { char *cp; + update_PROCINFO_num("errno", errcode); if (errcode) { cp = strerror(errcode); cp = gettext(cp); @@ -1040,6 +1040,7 @@ update_ERRNO_int(int errcode) void update_ERRNO_string(const char *string) { + update_PROCINFO_num("errno", 0); unref(ERRNO_node->var_value); ERRNO_node->var_value = make_string(string, strlen(string)); } @@ -1049,6 +1050,7 @@ update_ERRNO_string(const char *string) void unset_ERRNO(void) { + update_PROCINFO_num("errno", 0); unref(ERRNO_node->var_value); ERRNO_node->var_value = dupnode(Nnull_string); } diff --git a/extension/ChangeLog b/extension/ChangeLog index 41c8a0e4..e8fa12fd 100644 --- a/extension/ChangeLog +++ b/extension/ChangeLog @@ -1,8 +1,55 @@ +2015-01-02 Andrew J. Schorr <aschorr@telemetry-investments.com> + + Remove the select extension, since it will be part of gawkextlib. + * select.c, siglist.h: Deleted. + * Makefile.am (pkgextension_LTLIBRARIES): Remove select.la. + (select_la_SOURCES, select_la_LDFLAGS, select_la_LIBADD): Remove. + (EXTRA_DIST): Remove siglist.h. + * configure.ac (AC_CHECK_HEADERS): Remove signal.h. + (AC_CHECK_FUNCS): Remove fcntl, kill, sigaction, and sigprocmask. + +2014-12-14 Andrew J. Schorr <aschorr@telemetry-investments.com> + + Remove the errno extension, since it is now part of gawkextlib. + * errno.c, errlist.h: Deleted. + * Makefile.am (pkgextension_LTLIBRARIES): Remove errno.la. + (errno_la_SOURCES, errno_la_LDFLAGS, errno_la_LIBADD): Remove. + (EXTRA_DIST): Remove errlist.h. + 2014-11-23 Arnold D. Robbins <arnold@skeeve.com> * inplace.c (do_inplace_begin): Jump through hoops to silence GCC warnings about return value of chown. +2014-11-09 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * select.c (do_input_fd): New function to return the input file + descriptor associated with a file/command. + (do_output_fd): New function to return the output file descriptor + associated with a file/command. + (func_table): Add new functions "input_fd" and "output_fd". + * testext.c (test_get_file): Do not use __func__, since it is a C99 + feature, and gawk does not assume C99. + +2014-11-06 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * errno.c (do_errno2name, do_name2errno): Remove unused variable 'str'. + * select.c (do_signal): Remove unused variable 'override'. + (grabfd): New helper function to map a gawk file to the appropriate + fd for use in the arguments to selectd. + (do_select): get_file has 3 new arguments and returns info about both + the input and output buf. + (do_set_non_blocking): Support changes to get_file API. + * testext.c (test_get_file): New test function to check that extension + file creation via the get_file API is working. + +2014-11-05 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * select.c (set_retry): New function to set PROCINFO[<name>, "RETRY"]. + (do_set_non_blocking): If called with a file name as opposed to a file + descriptor, call the set_retry function to configure PROCINFO to tell + io.c to retry I/O for temporary failures. + 2014-10-12 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (uninstall-so): Remove *.lib too, per suggestion @@ -174,6 +221,108 @@ * gawkdirfd.h (FAKE_FD_VALUE): Move definition up in the file to give clean compile on MinGW. +2013-07-07 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * configure.ac (AC_CHECK_FUNCS): Check for fcntl. + * select.c (set_non_blocking): Check that fcntl and O_NONBLOCK are + available. + +2013-07-07 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * select.c (signal_handler): On platforms lacking sigaction, reset + the signal handler each time a signal is trapped to protect in case + the system resets it to default. + +2013-07-05 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * select.c (signal_result): New function to set result string from + signal function and detect when we need to roll back. + (do_signal): Now takes an optional 3rd override argument. Instead + of returning -1 or 0, we now return information about the previously + installed signal handler: default, ignore, trap, or unknown. An + empty string is returned on error. If it is an unknown handler, + and override is not non-zero, we roll back the handler and return "". + +2013-07-05 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * select.c (set_non_blocking): Do not attempt F_SETFL if F_GETFL fails. + (do_set_non_blocking): Add support for case when called with a single + "" argument. + +2013-07-05 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * select.c (do_signal): If sigaction is unavailable, fall back to + signal and hope that it does the right thing. + +2013-07-05 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * configure.ac (AC_CHECK_FUNCS): Add kill and sigprocmask. + * select.c (get_signal_number): Change error messages since now may + be called by "kill" as well as "select_signal". + (do_signal): Add a lint warning if there are more than 2 args. + (do_kill): Add new function to send a signal. + (do_select): Support platforms where sigprocmask is not available. + There will be a race condition on such platforms, but that is not + easily avoided. + +2013-07-02 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * select.c (do_select): Now that the API flatten_array call has been + patched to ensure that the index values are strings, we can remove + the code to check for the AWK_NUMBER case. + +2013-07-02 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * select.c (do_select): Do not treat a numeric command value as a + file descriptor unless the command type is empty. + +2013-07-02 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * Makefile.am (EXTRA_DIST): Add errlist.h and siglist.h. + +2013-07-02 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * select.c (set_non_blocking): New helper function to call fcntl. + (do_set_non_blocking): Add support for the case where there's a single + integer fd argument. + +2013-07-01 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * select.c (do_set_non_blocking): Implement new set_non_blocking + function. + (func_table): Add set_non_blocking. + +2013-07-01 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * errlist.h: New file containing a list of all the errno values I could + find. + * errno.c: Implement a new errno extension providing strerror, + errno2name, and name2errno. + * Makefile.am (pkgextension_LTLIBRARIES): Add errno.la. + (errno_la_SOURCES, errno_la_LDFLAGS, errno_la_LIBADD): Build new errno + extension. + * select.c (ext_version): Fix version string. + * siglist.h: Update to newest glibc version. + +2013-07-01 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * siglist.h: New file copied from glibc to provide a mapping between + signal number and name. + * select.c: Add a new "select_signal" function and provide support + for trapping signals. + (do_select): Add support for a 5th argument to contain an array + of returned signals. Improve the argument processing, and add + better warning messages. + +2013-06-30 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * Makefile.am (pkgextension_LTLIBRARIES): Add select.la. + (select_la_SOURCES, select_la_LDFLAGS, select_la_LIBADD): Build new + select extension. + * configure.ac (AC_CHECK_HEADERS): Add signal.h. + (AC_CHECK_FUNCS): Add sigaction. + * select.c: Implement the new select extension. + 2013-06-10 Arnold D. Robbins <arnold@skeeve.com> * configure.ac (AC_HEADER_MAJOR): New macro added. diff --git a/extension/testext.c b/extension/testext.c index 7462265b..f00ced7d 100644 --- a/extension/testext.c +++ b/extension/testext.c @@ -37,6 +37,7 @@ #include <sys/types.h> #include <sys/stat.h> +#include <fcntl.h> #include "gawkapi.h" @@ -710,6 +711,7 @@ BEGIN { ret = test_indirect_vars() # should get correct value of NR printf("test_indirect_var() return %d\n", ret) delete ARGV[1] + print "" } */ @@ -742,6 +744,63 @@ out: return result; } +/* +BEGIN { + outfile = "testexttmp.txt" + alias = ".test.alias" + print "line 1" > outfile + print "line 2" > outfile + print "line 3" > outfile + close(outfile) + ret = test_get_file(outfile, alias) + printf "test_get_file returned %d\n", ret + nr = 0 + while ((getline < alias) > 0) + printf "File [%s] nr [%s]: %s\n", alias, ++nr, $0 + close(alias) + system("rm " outfile) + print "" +} +*/ + +/* test_get_file --- test that we can create a file */ + +static awk_value_t * +test_get_file(int nargs, awk_value_t *result) +{ + awk_value_t filename, alias; + int fd; + const awk_input_buf_t *ibuf; + const awk_output_buf_t *obuf; + + if (nargs != 2) { + printf("%s: nargs not right (%d should be 2)\n", "test_get_file", nargs); + return make_number(-1.0, result); + } + + if (! get_argument(0, AWK_STRING, & filename)) { + printf("%s: cannot get first arg\n", "test_get_file"); + return make_number(-1.0, result); + } + if (! get_argument(1, AWK_STRING, & alias)) { + printf("%s: cannot get first arg\n", "test_get_file"); + return make_number(-1.0, result); + } + if ((fd = open(filename.str_value.str, O_RDONLY)) < 0) { + printf("%s: open(%s) failed\n", "test_get_file", filename.str_value.str); + return make_number(-1.0, result); + } + if (! get_file(alias.str_value.str, strlen(alias.str_value.str), "<", 1, fd, &ibuf, &obuf)) { + printf("%s: get_file(%s) failed\n", "test_get_file", alias.str_value.str); + return make_number(-1.0, result); + } + if (! ibuf || ibuf->fd != fd) { + printf("%s: get_file(%s) returned fd %d instead of %d\n", "test_get_file", alias.str_value.str, ibuf ? ibuf->fd : -1, fd); + return make_number(-1.0, result); + } + return make_number(0.0, result); +} + /* fill_in_array --- fill in a new array */ static void @@ -837,6 +896,7 @@ static awk_ext_func_t func_table[] = { { "test_scalar", test_scalar, 1 }, { "test_scalar_reserved", test_scalar_reserved, 0 }, { "test_indirect_vars", test_indirect_vars, 0 }, + { "test_get_file", test_get_file, 2 }, }; /* init_testext --- additional initialization function */ @@ -25,6 +25,11 @@ #include "awk.h" +/* Declare some globals used by api_get_file: */ +extern IOBUF *curfile; +extern INSTRUCTION *main_beginfile; +extern int currule; + static awk_bool_t node_to_awk_value(NODE *node, awk_value_t *result, awk_valtype_t wanted); /* @@ -1035,6 +1040,90 @@ api_release_value(awk_ext_id_t id, awk_value_cookie_t value) return awk_true; } +/* api_get_file --- return a handle to an existing or newly opened file */ + +static awk_bool_t +api_get_file(awk_ext_id_t id, const char *name, size_t namelen, const char *filetype, size_t typelen, int fd, const awk_input_buf_t **ibufp, const awk_output_buf_t **obufp) +{ + const struct redirect *f; + int flag; /* not used, sigh */ + enum redirval redirtype; + + if ((name == NULL) || (namelen == 0)) { + if (curfile == NULL) { + if (nextfile(& curfile, false) <= 0) + return awk_false; + { + INSTRUCTION *pc = main_beginfile; + /* save execution state */ + int save_rule = currule; + char *save_source = source; + + while (1) { + if (!pc) + fatal(_("cannot find end of BEGINFILE rule")); + if (pc->opcode == Op_after_beginfile) + break; + pc = pc->nexti; + } + pc->opcode = Op_stop; + (void) (*interpret)(main_beginfile); + pc->opcode = Op_after_beginfile; + after_beginfile(& curfile); + /* restore execution state */ + currule = save_rule; + source = save_source; + } + } + *ibufp = &curfile->public; + *obufp = NULL; + return awk_true; + } + redirtype = redirect_none; + switch (typelen) { + case 1: + switch (*filetype) { + case '<': + redirtype = redirect_input; + break; + case '>': + redirtype = redirect_output; + break; + } + break; + case 2: + switch (*filetype) { + case '>': + if (filetype[1] == '>') + redirtype = redirect_append; + break; + case '|': + switch (filetype[1]) { + case '>': + redirtype = redirect_pipe; + break; + case '<': + redirtype = redirect_pipein; + break; + case '&': + redirtype = redirect_twoway; + break; + } + break; + } + } + if (redirtype == redirect_none) { + warning(_("cannot open unrecognized file type `%s' for `%s'"), + filetype, name); + return awk_false; + } + if ((f = redirect_string(name, namelen, 0, redirtype, &flag, fd)) == NULL) + return awk_false; + *ibufp = f->iop ? & f->iop->public : NULL; + *obufp = f->output.fp ? & f->output : NULL; + return awk_true; +} + /* * Register a version string for this extension with gawk. */ @@ -1120,6 +1209,9 @@ gawk_api_t api_impl = { calloc, realloc, free, + + /* Find/open a file */ + api_get_file, }; /* init_ext_api --- init the extension API */ @@ -263,7 +263,7 @@ typedef struct awk_two_way_processor { /* Current version of the API. */ enum { GAWK_API_MAJOR_VERSION = 1, - GAWK_API_MINOR_VERSION = 1 + GAWK_API_MINOR_VERSION = 2 }; /* A number of typedefs related to different types of values. */ @@ -674,6 +674,39 @@ typedef struct gawk_api { void *(*api_calloc)(size_t nmemb, size_t size); void *(*api_realloc)(void *ptr, size_t size); void (*api_free)(void *ptr); + + /* + * Look up a file. If the name is NULL or name_len is 0, it returns + * data for the currently open input file corresponding to FILENAME + * (and it will not access the filetype or typelen arguments, so those + * may be undefined). + * If the file is not already open, it tries to open it. + * The "filetype" argument should be one of: + * ">", ">>", "<", "|>", "|<", and "|&" + * If the file is not already open, and the fd argument is non-negative, + * gawk will use that file descriptor instead of opening the file + * in the usual way. If the fd is non-negative, but the file exists + * already, gawk ignores the fd and returns the existing file. It is + * the caller's responsibility to notice that the fd in the returned + * awk_input_buf_t does not match the requested value. Note that + * supplying a file descriptor is currently NOT supported for pipes. + * It should work for input, output, append, and two-way (coprocess) + * sockets. If the filetype is two-way, we assume that it is a socket! + * Note that in the two-way case, the intput and output file descriptors + * may differ. To check for success, one must check that either of + * them matches. + */ + awk_bool_t (*api_get_file)(awk_ext_id_t id, + const char *name, + size_t name_len, + const char *filetype, + size_t typelen, int fd, + /* + * Return values (on success, one or both should + * be non-NULL): + */ + const awk_input_buf_t **ibufp, + const awk_output_buf_t **obufp); } gawk_api_t; #ifndef GAWK /* these are not for the gawk code itself! */ @@ -756,6 +789,9 @@ typedef struct gawk_api { #define release_value(value) \ (api->api_release_value(ext_id, value)) +#define get_file(name, namelen, filetype, typelen, fd, ibuf, obuf) \ + (api->api_get_file(ext_id, name, namelen, filetype, typelen, fd, ibuf, obuf)) + #define register_ext_version(version) \ (api->api_register_ext_version(ext_id, version)) @@ -272,7 +272,7 @@ static IOBUF *iop_alloc(int fd, const char *name, int errno_val); static IOBUF *iop_finish(IOBUF *iop); static int gawk_pclose(struct redirect *rp); static int str2mode(const char *mode); -static int two_way_open(const char *str, struct redirect *rp); +static int two_way_open(const char *str, struct redirect *rp, int extfd); static int pty_vs_pipe(const char *command); static void find_input_parser(IOBUF *iop); static bool find_output_wrapper(awk_output_buf_t *outbuf); @@ -596,7 +596,8 @@ inrec(IOBUF *iop, int *errcode) else cnt = get_a_record(& begin, iop, errcode); - if (cnt == EOF) { + /* Note that get_a_record may return -2 when I/O would block */ + if (cnt < 0) { retval = false; } else { INCREMENT_REC(NR); @@ -727,10 +728,9 @@ redflags2str(int flags) /* redirect --- Redirection for printf and print commands */ struct redirect * -redirect(NODE *redir_exp, int redirtype, int *errflg) +redirect_string(const char *str, size_t explen, int not_string, int redirtype, int *errflg, int extfd) { struct redirect *rp; - char *str; int tflag = 0; int outflag = 0; const char *direction = "to"; @@ -779,18 +779,16 @@ redirect(NODE *redir_exp, int redirtype, int *errflg) default: cant_happen(); } - if (do_lint && (redir_exp->flags & STRCUR) == 0) + if (do_lint && not_string) lintwarn(_("expression in `%s' redirection only has numeric value"), what); - redir_exp = force_string(redir_exp); - str = redir_exp->stptr; if (str == NULL || *str == '\0') fatal(_("expression for `%s' redirection has null string value"), what); - if (do_lint && (strncmp(str, "0", redir_exp->stlen) == 0 - || strncmp(str, "1", redir_exp->stlen) == 0)) + if (do_lint && (strncmp(str, "0", explen) == 0 + || strncmp(str, "1", explen) == 0)) lintwarn(_("filename `%s' for `%s' redirection may be result of logical expression"), str, what); @@ -828,8 +826,8 @@ redirect(NODE *redir_exp, int redirtype, int *errflg) #endif /* PIPES_SIMULATED */ /* now check for a match */ - if (strlen(rp->value) == redir_exp->stlen - && memcmp(rp->value, str, redir_exp->stlen) == 0 + if (strlen(rp->value) == explen + && memcmp(rp->value, str, explen) == 0 && ((rp->flag & ~(RED_NOBUF|RED_EOF|RED_PTY)) == tflag || (outflag != 0 && (rp->flag & (RED_FILE|RED_WRITE)) == outflag))) { @@ -840,23 +838,25 @@ redirect(NODE *redir_exp, int redirtype, int *errflg) if (do_lint && rpflag != newflag) lintwarn( _("unnecessary mixing of `>' and `>>' for file `%.*s'"), - (int) redir_exp->stlen, rp->value); + (int) explen, rp->value); break; } } if (rp == NULL) { + char *newstr; new_rp = true; if (save_rp != NULL) { rp = save_rp; efree(rp->value); } else emalloc(rp, struct redirect *, sizeof(struct redirect), "redirect"); - emalloc(str, char *, redir_exp->stlen + 1, "redirect"); - memcpy(str, redir_exp->stptr, redir_exp->stlen); - str[redir_exp->stlen] = '\0'; - rp->value = str; + emalloc(newstr, char *, explen + 1, "redirect"); + memcpy(newstr, str, explen); + newstr[explen] = '\0'; + str = newstr; + rp->value = newstr; rp->flag = tflag; init_output_wrapper(& rp->output); rp->output.name = str; @@ -888,6 +888,10 @@ redirect(NODE *redir_exp, int redirtype, int *errflg) mode = binmode("a"); break; case redirect_pipe: + if (extfd >= 0) { + warning(_("get_file cannot create pipe `%s' with fd %d"), str, extfd); + return NULL; + } /* synchronize output before new pipe */ (void) flush_io(); @@ -901,6 +905,10 @@ redirect(NODE *redir_exp, int redirtype, int *errflg) rp->flag |= RED_NOBUF; break; case redirect_pipein: + if (extfd >= 0) { + warning(_("get_file cannot create pipe `%s' with fd %d"), str, extfd); + return NULL; + } direction = "from"; if (gawk_popen(str, rp) == NULL) fatal(_("can't open pipe `%s' for input (%s)"), @@ -908,7 +916,7 @@ redirect(NODE *redir_exp, int redirtype, int *errflg) break; case redirect_input: direction = "from"; - fd = devopen(str, binmode("r")); + fd = (extfd >= 0) ? extfd : devopen(str, binmode("r")); if (fd == INVALID_HANDLE && errno == EISDIR) { *errflg = EISDIR; /* do not free rp, saving it for reuse (save_rp = rp) */ @@ -925,8 +933,14 @@ redirect(NODE *redir_exp, int redirtype, int *errflg) } break; case redirect_twoway: +#ifndef HAVE_SOCKETS + if (extfd >= 0) { + warning(_("get_file socket creation not supported on this platform for `%s' with fd %d"), str, extfd); + return NULL; + } +#endif direction = "to/from"; - if (! two_way_open(str, rp)) { + if (! two_way_open(str, rp, extfd)) { #ifdef HAVE_SOCKETS if (inetfile(str, NULL)) { *errflg = errno; @@ -945,7 +959,7 @@ redirect(NODE *redir_exp, int redirtype, int *errflg) if (mode != NULL) { errno = 0; rp->output.mode = mode; - fd = devopen(str, mode); + fd = (extfd >= 0) ? extfd : devopen(str, mode); if (fd > INVALID_HANDLE) { if (fd == fileno(stdin)) @@ -1044,6 +1058,15 @@ redirect(NODE *redir_exp, int redirtype, int *errflg) return rp; } +struct redirect * +redirect(NODE *redir_exp, int redirtype, int *errflg) +{ + int not_string = ((redir_exp->flags & STRCUR) == 0); + redir_exp = force_string(redir_exp); + return redirect_string(redir_exp->stptr, redir_exp->stlen, not_string, + redirtype, errflg, -1); +} + /* getredirect --- find the struct redirect for this file or pipe */ struct redirect * @@ -1699,16 +1722,16 @@ strictopen: /* two_way_open --- open a two way communications channel */ static int -two_way_open(const char *str, struct redirect *rp) +two_way_open(const char *str, struct redirect *rp, int extfd) { static bool no_ptys = false; #ifdef HAVE_SOCKETS /* case 1: socket */ - if (inetfile(str, NULL)) { + if (extfd >= 0 || inetfile(str, NULL)) { int fd, newfd; - fd = devopen(str, "rw"); + fd = (extfd >= 0) ? extfd : devopen(str, "rw"); if (fd == INVALID_HANDLE) return false; if ((BINMODE & BINMODE_OUTPUT) != 0) @@ -2168,17 +2191,43 @@ use_pipes: #ifndef PIPES_SIMULATED /* real pipes */ -/* wait_any --- wait for a child process, close associated pipe */ +/* + * wait_any --- if the argument pid is 0, wait for all child processes that + * have exited. We loop to make sure to reap all children that have exited to + * minimize the risk of running out of process slots. Since we don't process + * SIGCHLD, we do not immediately reap exited children. So when we get here, + * we want to reap any that have piled up. + * + * Note: on platforms that do not support waitpid with WNOHANG, when called with + * a zero argument, this function will hang until all children have exited. + * + * AJS, 2013-07-07: I do not see why we need to ignore signals during this + * function. This function just waits and updates the pid and status fields. + * I don't see why that should interfere with any signal handlers. But I am + * reluctant to remove this protection. So I changed to use sigprocmask to + * block signals instead to avoid interfering with installed signal handlers. + */ static int wait_any(int interesting) /* pid of interest, if any */ { - RETSIGTYPE (*hstat)(int), (*istat)(int), (*qstat)(int); int pid; int status = 0; struct redirect *redp; +#ifdef HAVE_SIGPROCMASK + sigset_t set, oldset; + + /* I have no idea why we are blocking signals during this function... */ + sigemptyset(& set); + sigaddset(& set, SIGINT); + sigaddset(& set, SIGHUP); + sigaddset(& set, SIGQUIT); + sigprocmask(SIG_BLOCK, & set, & oldset); +#else + RETSIGTYPE (*hstat)(int), (*istat)(int), (*qstat)(int); istat = signal(SIGINT, SIG_IGN); +#endif #ifdef __MINGW32__ if (interesting < 0) { status = -1; @@ -2195,10 +2244,16 @@ wait_any(int interesting) /* pid of interest, if any */ } } #else +#ifndef HAVE_SIGPROCMASK hstat = signal(SIGHUP, SIG_IGN); qstat = signal(SIGQUIT, SIG_IGN); +#endif for (;;) { -# ifdef HAVE_SYS_WAIT_H /* POSIX compatible sys/wait.h */ +# if defined(HAVE_WAITPID) && defined(WNOHANG) + if ((pid = waitpid(-1, & status, WNOHANG)) == 0) + /* No children have exited */ + break; +# elif defined(HAVE_SYS_WAIT_H) /* POSIX compatible sys/wait.h */ pid = wait(& status); # else pid = wait((union wait *) & status); @@ -2216,10 +2271,16 @@ wait_any(int interesting) /* pid of interest, if any */ if (pid == -1 && errno == ECHILD) break; } +#ifndef HAVE_SIGPROCMASK signal(SIGHUP, hstat); signal(SIGQUIT, qstat); #endif +#endif +#ifndef HAVE_SIGPROCMASK signal(SIGINT, istat); +#else + sigprocmask(SIG_SETMASK, & oldset, NULL); +#endif return status; } @@ -2440,7 +2501,7 @@ do_getline_redir(int into_variable, enum redirval redirtype) if (errcode != 0) { if (! do_traditional && (errcode != -1)) update_ERRNO_int(errcode); - return make_number((AWKNUM) -1.0); + return make_number((AWKNUM) cnt); } if (cnt == EOF) { @@ -2490,7 +2551,7 @@ do_getline(int into_variable, IOBUF *iop) update_ERRNO_int(errcode); if (into_variable) (void) POP_ADDRESS(); - return make_number((AWKNUM) -1.0); + return make_number((AWKNUM) cnt); } if (cnt == EOF) @@ -3383,10 +3444,44 @@ find_longest_terminator: return REC_OK; } +/* return true if PROCINFO[<filename>, "RETRY"] exists */ +static inline int +retryable(IOBUF *iop) +{ + return PROCINFO_node && in_PROCINFO(iop->public.name, "RETRY", NULL); +} + +/* Does the I/O error indicate that the operation should be retried later? */ + +static inline int +errno_io_retry(void) +{ + switch (errno) { +#ifdef EAGAIN + case EAGAIN: +#endif +#ifdef EWOULDBLOCK +#if !defined(EAGAIN) || (EWOULDBLOCK != EAGAIN) + case EWOULDBLOCK: +#endif +#endif +#ifdef EINTR + case EINTR: +#endif +#ifdef ETIMEDOUT + case ETIMEDOUT: +#endif + return 1; + default: + return 0; + } +} + /* * get_a_record --- read a record from IOP into out, * return length of EOF, set RT. * Note that errcode is never NULL, and the caller initializes *errcode to 0. + * If I/O would block, return -2. */ static int @@ -3430,8 +3525,10 @@ get_a_record(char **out, /* pointer to pointer to data */ iop->flag |= IOP_AT_EOF; return EOF; } else if (iop->count == -1) { - iop->flag |= IOP_AT_EOF; *errcode = errno; + if (errno_io_retry() && retryable(iop)) + return -2; + iop->flag |= IOP_AT_EOF; return EOF; } else { iop->dataend = iop->buf + iop->count; @@ -3505,6 +3602,8 @@ get_a_record(char **out, /* pointer to pointer to data */ iop->count = iop->public.read_func(iop->public.fd, iop->dataend, amt_to_read); if (iop->count == -1) { *errcode = errno; + if (errno_io_retry() && retryable(iop)) + return -2; iop->flag |= IOP_AT_EOF; break; } else if (iop->count == 0) { diff --git a/test/ChangeLog b/test/ChangeLog index 2787b909..7ff3e422 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -32,6 +32,10 @@ * mbprintf4.awk: Add record and line number for debugging. * mpprint4.ok: Adjust. +2014-11-06 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * testext.ok: Add results from new test_get_file test. + 2014-11-02 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (profile7): New test. diff --git a/test/testext.ok b/test/testext.ok index 9b36bf72..5a78c159 100644 --- a/test/testext.ok +++ b/test/testext.ok @@ -69,6 +69,12 @@ test_scalar_reserved: could not update new_value2 for ARGC - pass test_indirect_var: sym_lookup of NR passed test_indirect_var: value of NR is 3 test_indirect_var() return 1 + +test_get_file returned 0 +File [.test.alias] nr [1]: line 1 +File [.test.alias] nr [2]: line 2 +File [.test.alias] nr [3]: line 3 + answer_num = 42 message_string = hello, world new_array["hello"] = "world" |