aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog77
-rw-r--r--awk.h1
-rw-r--r--awkgram.c721
-rw-r--r--awkgram.y3
-rw-r--r--configh.in6
-rwxr-xr-xconfigure5
-rw-r--r--configure.ac5
-rw-r--r--eval.c3
-rw-r--r--extension/ChangeLog102
-rw-r--r--extension/Makefile.am14
-rw-r--r--extension/Makefile.in60
-rw-r--r--extension/configh.in15
-rwxr-xr-xextension/configure7
-rw-r--r--extension/configure.ac7
-rw-r--r--extension/errlist.h455
-rw-r--r--extension/errno.c145
-rw-r--r--extension/select.c544
-rw-r--r--extension/siglist.h76
-rw-r--r--gawkapi.c88
-rw-r--r--gawkapi.h20
-rw-r--r--io.c118
21 files changed, 2065 insertions, 407 deletions
diff --git a/ChangeLog b/ChangeLog
index ed4c2b9a..4cf75d0f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1157,6 +1157,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
@@ -1167,6 +1206,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
diff --git a/awk.h b/awk.h
index c59c4bf9..1f4364ad 100644
--- a/awk.h
+++ b/awk.h
@@ -1524,6 +1524,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(char *redir_exp_str, size_t redir_exp_len, int not_string_flag, int redirtype, int *errflg);
extern NODE *do_close(int nargs);
extern int flush_io(void);
extern int close_io(bool *stdio_problem);
diff --git a/awkgram.c b/awkgram.c
index a79f9a30..7cbb2be6 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -186,6 +186,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;
@@ -202,7 +203,7 @@ extern double fmod(double x, double y);
#define YYSTYPE INSTRUCTION *
-#line 206 "awkgram.c" /* yacc.c:339 */
+#line 207 "awkgram.c" /* yacc.c:339 */
# ifndef YY_NULLPTR
# if defined __cplusplus && 201103L <= __cplusplus
@@ -356,7 +357,7 @@ int yyparse (void);
/* Copy the second part of user declarations. */
-#line 360 "awkgram.c" /* yacc.c:358 */
+#line 361 "awkgram.c" /* yacc.c:358 */
#ifdef short
# undef short
@@ -658,25 +659,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, 206, 206, 208, 213, 214, 220, 232, 236, 247,
+ 253, 258, 266, 274, 276, 281, 289, 291, 297, 305,
+ 315, 341, 354, 367, 374, 384, 396, 398, 400, 406,
+ 411, 412, 416, 451, 450, 484, 486, 491, 497, 525,
+ 530, 531, 535, 537, 539, 546, 636, 678, 720, 833,
+ 840, 847, 857, 866, 875, 884, 895, 911, 910, 934,
+ 946, 946, 1044, 1044, 1077, 1107, 1113, 1114, 1120, 1121,
+ 1128, 1133, 1145, 1159, 1161, 1169, 1174, 1176, 1184, 1186,
+ 1195, 1196, 1204, 1209, 1209, 1220, 1224, 1232, 1233, 1236,
+ 1238, 1243, 1244, 1253, 1254, 1259, 1264, 1270, 1272, 1274,
+ 1281, 1282, 1288, 1289, 1294, 1296, 1301, 1303, 1311, 1316,
+ 1325, 1332, 1334, 1336, 1352, 1362, 1369, 1371, 1376, 1378,
+ 1380, 1388, 1390, 1395, 1397, 1402, 1404, 1406, 1456, 1458,
+ 1460, 1462, 1464, 1466, 1468, 1470, 1484, 1489, 1494, 1519,
+ 1525, 1527, 1529, 1531, 1533, 1535, 1540, 1544, 1576, 1578,
+ 1584, 1590, 1603, 1604, 1605, 1610, 1615, 1619, 1623, 1638,
+ 1651, 1656, 1692, 1710, 1711, 1717, 1718, 1723, 1725, 1732,
+ 1749, 1766, 1768, 1775, 1780, 1788, 1798, 1810, 1819, 1823,
+ 1827, 1831, 1835, 1839, 1842, 1844, 1848, 1852, 1856
};
#endif
@@ -1849,26 +1850,26 @@ yyreduce:
switch (yyn)
{
case 3:
-#line 208 "awkgram.y" /* yacc.c:1646 */
+#line 209 "awkgram.y" /* yacc.c:1646 */
{
rule = 0;
yyerrok;
}
-#line 1858 "awkgram.c" /* yacc.c:1646 */
+#line 1859 "awkgram.c" /* yacc.c:1646 */
break;
case 5:
-#line 214 "awkgram.y" /* yacc.c:1646 */
+#line 215 "awkgram.y" /* yacc.c:1646 */
{
next_sourcefile();
if (sourcefile == srcfiles)
process_deferred();
}
-#line 1868 "awkgram.c" /* yacc.c:1646 */
+#line 1869 "awkgram.c" /* yacc.c:1646 */
break;
case 6:
-#line 220 "awkgram.y" /* yacc.c:1646 */
+#line 221 "awkgram.y" /* yacc.c:1646 */
{
rule = 0;
/*
@@ -1877,19 +1878,19 @@ yyreduce:
*/
/* yyerrok; */
}
-#line 1881 "awkgram.c" /* yacc.c:1646 */
+#line 1882 "awkgram.c" /* yacc.c:1646 */
break;
case 7:
-#line 232 "awkgram.y" /* yacc.c:1646 */
+#line 233 "awkgram.y" /* yacc.c:1646 */
{
(void) append_rule((yyvsp[-1]), (yyvsp[0]));
}
-#line 1889 "awkgram.c" /* yacc.c:1646 */
+#line 1890 "awkgram.c" /* yacc.c:1646 */
break;
case 8:
-#line 236 "awkgram.y" /* yacc.c:1646 */
+#line 237 "awkgram.y" /* yacc.c:1646 */
{
if (rule != Rule) {
msg(_("%s blocks must have an action part"), ruletab[rule]);
@@ -1900,39 +1901,39 @@ yyreduce:
} else /* pattern rule with non-empty pattern */
(void) append_rule((yyvsp[-1]), NULL);
}
-#line 1904 "awkgram.c" /* yacc.c:1646 */
+#line 1905 "awkgram.c" /* yacc.c:1646 */
break;
case 9:
-#line 247 "awkgram.y" /* yacc.c:1646 */
+#line 248 "awkgram.y" /* yacc.c:1646 */
{
in_function = NULL;
(void) mk_function((yyvsp[-1]), (yyvsp[0]));
yyerrok;
}
-#line 1914 "awkgram.c" /* yacc.c:1646 */
+#line 1915 "awkgram.c" /* yacc.c:1646 */
break;
case 10:
-#line 253 "awkgram.y" /* yacc.c:1646 */
+#line 254 "awkgram.y" /* yacc.c:1646 */
{
want_source = false;
yyerrok;
}
-#line 1923 "awkgram.c" /* yacc.c:1646 */
+#line 1924 "awkgram.c" /* yacc.c:1646 */
break;
case 11:
-#line 258 "awkgram.y" /* yacc.c:1646 */
+#line 259 "awkgram.y" /* yacc.c:1646 */
{
want_source = false;
yyerrok;
}
-#line 1932 "awkgram.c" /* yacc.c:1646 */
+#line 1933 "awkgram.c" /* yacc.c:1646 */
break;
case 12:
-#line 266 "awkgram.y" /* yacc.c:1646 */
+#line 267 "awkgram.y" /* yacc.c:1646 */
{
if (include_source((yyvsp[0])) < 0)
YYABORT;
@@ -1940,23 +1941,23 @@ yyreduce:
bcfree((yyvsp[0]));
(yyval) = NULL;
}
-#line 1944 "awkgram.c" /* yacc.c:1646 */
+#line 1945 "awkgram.c" /* yacc.c:1646 */
break;
case 13:
-#line 274 "awkgram.y" /* yacc.c:1646 */
+#line 275 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 1950 "awkgram.c" /* yacc.c:1646 */
+#line 1951 "awkgram.c" /* yacc.c:1646 */
break;
case 14:
-#line 276 "awkgram.y" /* yacc.c:1646 */
+#line 277 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 1956 "awkgram.c" /* yacc.c:1646 */
+#line 1957 "awkgram.c" /* yacc.c:1646 */
break;
case 15:
-#line 281 "awkgram.y" /* yacc.c:1646 */
+#line 282 "awkgram.y" /* yacc.c:1646 */
{
if (load_library((yyvsp[0])) < 0)
YYABORT;
@@ -1964,23 +1965,23 @@ yyreduce:
bcfree((yyvsp[0]));
(yyval) = NULL;
}
-#line 1968 "awkgram.c" /* yacc.c:1646 */
+#line 1969 "awkgram.c" /* yacc.c:1646 */
break;
case 16:
-#line 289 "awkgram.y" /* yacc.c:1646 */
+#line 290 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 1974 "awkgram.c" /* yacc.c:1646 */
+#line 1975 "awkgram.c" /* yacc.c:1646 */
break;
case 17:
-#line 291 "awkgram.y" /* yacc.c:1646 */
+#line 292 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 1980 "awkgram.c" /* yacc.c:1646 */
+#line 1981 "awkgram.c" /* yacc.c:1646 */
break;
case 18:
-#line 296 "awkgram.y" /* yacc.c:1646 */
+#line 297 "awkgram.y" /* yacc.c:1646 */
{
rule = Rule;
if (comment != NULL) {
@@ -1989,11 +1990,11 @@ yyreduce:
} else
(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) {
@@ -2002,11 +2003,11 @@ yyreduce:
} else
(yyval) = (yyvsp[0]);
}
-#line 2006 "awkgram.c" /* yacc.c:1646 */
+#line 2007 "awkgram.c" /* yacc.c:1646 */
break;
case 20:
-#line 315 "awkgram.y" /* yacc.c:1646 */
+#line 316 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *tp;
@@ -2032,11 +2033,11 @@ yyreduce:
(yyval) = list_append(list_merge((yyvsp[-3]), (yyvsp[0])), tp);
rule = Rule;
}
-#line 2036 "awkgram.c" /* yacc.c:1646 */
+#line 2037 "awkgram.c" /* yacc.c:1646 */
break;
case 21:
-#line 341 "awkgram.y" /* yacc.c:1646 */
+#line 342 "awkgram.y" /* yacc.c:1646 */
{
static int begin_seen = 0;
@@ -2049,11 +2050,11 @@ yyreduce:
(yyvsp[0])->source_file = source;
(yyval) = (yyvsp[0]);
}
-#line 2053 "awkgram.c" /* yacc.c:1646 */
+#line 2054 "awkgram.c" /* yacc.c:1646 */
break;
case 22:
-#line 354 "awkgram.y" /* yacc.c:1646 */
+#line 355 "awkgram.y" /* yacc.c:1646 */
{
static int end_seen = 0;
@@ -2066,33 +2067,33 @@ yyreduce:
(yyvsp[0])->source_file = source;
(yyval) = (yyvsp[0]);
}
-#line 2070 "awkgram.c" /* yacc.c:1646 */
+#line 2071 "awkgram.c" /* yacc.c:1646 */
break;
case 23:
-#line 367 "awkgram.y" /* yacc.c:1646 */
+#line 368 "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 2082 "awkgram.c" /* yacc.c:1646 */
break;
case 24:
-#line 374 "awkgram.y" /* yacc.c:1646 */
+#line 375 "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 2093 "awkgram.c" /* yacc.c:1646 */
break;
case 25:
-#line 384 "awkgram.y" /* yacc.c:1646 */
+#line 385 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *ip;
if ((yyvsp[-3]) == NULL)
@@ -2101,39 +2102,39 @@ yyreduce:
ip = (yyvsp[-3]);
(yyval) = ip;
}
-#line 2105 "awkgram.c" /* yacc.c:1646 */
+#line 2106 "awkgram.c" /* yacc.c:1646 */
break;
case 26:
-#line 396 "awkgram.y" /* yacc.c:1646 */
+#line 397 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 2111 "awkgram.c" /* yacc.c:1646 */
+#line 2112 "awkgram.c" /* yacc.c:1646 */
break;
case 27:
-#line 398 "awkgram.y" /* yacc.c:1646 */
+#line 399 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 2117 "awkgram.c" /* yacc.c:1646 */
+#line 2118 "awkgram.c" /* yacc.c:1646 */
break;
case 28:
-#line 400 "awkgram.y" /* yacc.c:1646 */
+#line 401 "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 2128 "awkgram.c" /* yacc.c:1646 */
break;
case 29:
-#line 406 "awkgram.y" /* yacc.c:1646 */
+#line 407 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 2133 "awkgram.c" /* yacc.c:1646 */
+#line 2134 "awkgram.c" /* yacc.c:1646 */
break;
case 32:
-#line 416 "awkgram.y" /* yacc.c:1646 */
+#line 417 "awkgram.y" /* yacc.c:1646 */
{
/*
* treat any comments between BOF and the first function
@@ -2160,17 +2161,17 @@ yyreduce:
/* $4 already free'd in install_function */
(yyval) = (yyvsp[-5]);
}
-#line 2164 "awkgram.c" /* yacc.c:1646 */
+#line 2165 "awkgram.c" /* yacc.c:1646 */
break;
case 33:
-#line 450 "awkgram.y" /* yacc.c:1646 */
+#line 451 "awkgram.y" /* yacc.c:1646 */
{ want_regexp = true; }
-#line 2170 "awkgram.c" /* yacc.c:1646 */
+#line 2171 "awkgram.c" /* yacc.c:1646 */
break;
case 34:
-#line 452 "awkgram.y" /* yacc.c:1646 */
+#line 453 "awkgram.y" /* yacc.c:1646 */
{
NODE *n, *exp;
char *re;
@@ -2199,28 +2200,28 @@ yyreduce:
(yyval)->opcode = Op_match_rec;
(yyval)->memory = n;
}
-#line 2203 "awkgram.c" /* yacc.c:1646 */
+#line 2204 "awkgram.c" /* yacc.c:1646 */
break;
case 35:
-#line 484 "awkgram.y" /* yacc.c:1646 */
+#line 485 "awkgram.y" /* yacc.c:1646 */
{ bcfree((yyvsp[0])); }
-#line 2209 "awkgram.c" /* yacc.c:1646 */
+#line 2210 "awkgram.c" /* yacc.c:1646 */
break;
case 37:
-#line 490 "awkgram.y" /* yacc.c:1646 */
+#line 491 "awkgram.y" /* yacc.c:1646 */
{
if (comment != NULL) {
(yyval) = list_create(comment);
comment = NULL;
} else (yyval) = NULL;
}
-#line 2220 "awkgram.c" /* yacc.c:1646 */
+#line 2221 "awkgram.c" /* yacc.c:1646 */
break;
case 38:
-#line 497 "awkgram.y" /* yacc.c:1646 */
+#line 498 "awkgram.y" /* yacc.c:1646 */
{
if ((yyvsp[0]) == NULL) {
if (comment == NULL)
@@ -2248,40 +2249,40 @@ yyreduce:
}
yyerrok;
}
-#line 2252 "awkgram.c" /* yacc.c:1646 */
+#line 2253 "awkgram.c" /* yacc.c:1646 */
break;
case 39:
-#line 525 "awkgram.y" /* yacc.c:1646 */
+#line 526 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 2258 "awkgram.c" /* yacc.c:1646 */
+#line 2259 "awkgram.c" /* yacc.c:1646 */
break;
case 42:
-#line 535 "awkgram.y" /* yacc.c:1646 */
+#line 536 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 2264 "awkgram.c" /* yacc.c:1646 */
+#line 2265 "awkgram.c" /* yacc.c:1646 */
break;
case 43:
-#line 537 "awkgram.y" /* yacc.c:1646 */
+#line 538 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[-1]); }
-#line 2270 "awkgram.c" /* yacc.c:1646 */
+#line 2271 "awkgram.c" /* yacc.c:1646 */
break;
case 44:
-#line 539 "awkgram.y" /* yacc.c:1646 */
+#line 540 "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 2282 "awkgram.c" /* yacc.c:1646 */
break;
case 45:
-#line 546 "awkgram.y" /* yacc.c:1646 */
+#line 547 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *dflt, *curr = NULL, *cexp, *cstmt;
INSTRUCTION *ip, *nextc, *tbreak;
@@ -2371,11 +2372,11 @@ yyreduce:
break_allowed--;
fix_break_continue(ip, tbreak, NULL);
}
-#line 2375 "awkgram.c" /* yacc.c:1646 */
+#line 2376 "awkgram.c" /* yacc.c:1646 */
break;
case 46:
-#line 636 "awkgram.y" /* yacc.c:1646 */
+#line 637 "awkgram.y" /* yacc.c:1646 */
{
/*
* -----------------
@@ -2417,11 +2418,11 @@ yyreduce:
continue_allowed--;
fix_break_continue(ip, tbreak, tcont);
}
-#line 2421 "awkgram.c" /* yacc.c:1646 */
+#line 2422 "awkgram.c" /* yacc.c:1646 */
break;
case 47:
-#line 678 "awkgram.y" /* yacc.c:1646 */
+#line 679 "awkgram.y" /* yacc.c:1646 */
{
/*
* -----------------
@@ -2463,11 +2464,11 @@ yyreduce:
} /* else
$1 and $4 are NULLs */
}
-#line 2467 "awkgram.c" /* yacc.c:1646 */
+#line 2468 "awkgram.c" /* yacc.c:1646 */
break;
case 48:
-#line 720 "awkgram.y" /* yacc.c:1646 */
+#line 721 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *ip;
char *var_name = (yyvsp[-5])->lextok;
@@ -2580,44 +2581,44 @@ regular_loop:
break_allowed--;
continue_allowed--;
}
-#line 2584 "awkgram.c" /* yacc.c:1646 */
+#line 2585 "awkgram.c" /* yacc.c:1646 */
break;
case 49:
-#line 833 "awkgram.y" /* yacc.c:1646 */
+#line 834 "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 2596 "awkgram.c" /* yacc.c:1646 */
break;
case 50:
-#line 840 "awkgram.y" /* yacc.c:1646 */
+#line 841 "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 2607 "awkgram.c" /* yacc.c:1646 */
break;
case 51:
-#line 847 "awkgram.y" /* yacc.c:1646 */
+#line 848 "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 2618 "awkgram.c" /* yacc.c:1646 */
break;
case 52:
-#line 857 "awkgram.y" /* yacc.c:1646 */
+#line 858 "awkgram.y" /* yacc.c:1646 */
{
if (! break_allowed)
error_ln((yyvsp[-1])->source_line,
@@ -2626,11 +2627,11 @@ regular_loop:
(yyval) = list_create((yyvsp[-1]));
}
-#line 2630 "awkgram.c" /* yacc.c:1646 */
+#line 2631 "awkgram.c" /* yacc.c:1646 */
break;
case 53:
-#line 866 "awkgram.y" /* yacc.c:1646 */
+#line 867 "awkgram.y" /* yacc.c:1646 */
{
if (! continue_allowed)
error_ln((yyvsp[-1])->source_line,
@@ -2639,11 +2640,11 @@ regular_loop:
(yyval) = list_create((yyvsp[-1]));
}
-#line 2643 "awkgram.c" /* yacc.c:1646 */
+#line 2644 "awkgram.c" /* yacc.c:1646 */
break;
case 54:
-#line 875 "awkgram.y" /* yacc.c:1646 */
+#line 876 "awkgram.y" /* yacc.c:1646 */
{
/* if inside function (rule = 0), resolve context at run-time */
if (rule && rule != Rule)
@@ -2652,11 +2653,11 @@ regular_loop:
(yyvsp[-1])->target_jmp = ip_rec;
(yyval) = list_create((yyvsp[-1]));
}
-#line 2656 "awkgram.c" /* yacc.c:1646 */
+#line 2657 "awkgram.c" /* yacc.c:1646 */
break;
case 55:
-#line 884 "awkgram.y" /* yacc.c:1646 */
+#line 885 "awkgram.y" /* yacc.c:1646 */
{
/* if inside function (rule = 0), resolve context at run-time */
if (rule == BEGIN || rule == END || rule == ENDFILE)
@@ -2667,11 +2668,11 @@ regular_loop:
(yyvsp[-1])->target_endfile = ip_endfile;
(yyval) = list_create((yyvsp[-1]));
}
-#line 2671 "awkgram.c" /* yacc.c:1646 */
+#line 2672 "awkgram.c" /* yacc.c:1646 */
break;
case 56:
-#line 895 "awkgram.y" /* yacc.c:1646 */
+#line 896 "awkgram.y" /* yacc.c:1646 */
{
/* Initialize the two possible jump targets, the actual target
* is resolved at run-time.
@@ -2686,20 +2687,20 @@ regular_loop:
} else
(yyval) = list_append((yyvsp[-1]), (yyvsp[-2]));
}
-#line 2690 "awkgram.c" /* yacc.c:1646 */
+#line 2691 "awkgram.c" /* yacc.c:1646 */
break;
case 57:
-#line 910 "awkgram.y" /* yacc.c:1646 */
+#line 911 "awkgram.y" /* yacc.c:1646 */
{
if (! in_function)
yyerror(_("`return' used outside function context"));
}
-#line 2699 "awkgram.c" /* yacc.c:1646 */
+#line 2700 "awkgram.c" /* yacc.c:1646 */
break;
case 58:
-#line 913 "awkgram.y" /* yacc.c:1646 */
+#line 914 "awkgram.y" /* yacc.c:1646 */
{
if ((yyvsp[-1]) == NULL) {
(yyval) = list_create((yyvsp[-3]));
@@ -2720,17 +2721,17 @@ regular_loop:
(yyval) = list_append((yyvsp[-1]), (yyvsp[-3]));
}
}
-#line 2724 "awkgram.c" /* yacc.c:1646 */
+#line 2725 "awkgram.c" /* yacc.c:1646 */
break;
case 60:
-#line 945 "awkgram.y" /* yacc.c:1646 */
+#line 946 "awkgram.y" /* yacc.c:1646 */
{ in_print = true; in_parens = 0; }
-#line 2730 "awkgram.c" /* yacc.c:1646 */
+#line 2731 "awkgram.c" /* yacc.c:1646 */
break;
case 61:
-#line 946 "awkgram.y" /* yacc.c:1646 */
+#line 947 "awkgram.y" /* yacc.c:1646 */
{
/*
* Optimization: plain `print' has no expression list, so $3 is null.
@@ -2827,17 +2828,17 @@ regular_print:
}
}
}
-#line 2831 "awkgram.c" /* yacc.c:1646 */
+#line 2832 "awkgram.c" /* yacc.c:1646 */
break;
case 62:
-#line 1043 "awkgram.y" /* yacc.c:1646 */
+#line 1044 "awkgram.y" /* yacc.c:1646 */
{ sub_counter = 0; }
-#line 2837 "awkgram.c" /* yacc.c:1646 */
+#line 2838 "awkgram.c" /* yacc.c:1646 */
break;
case 63:
-#line 1044 "awkgram.y" /* yacc.c:1646 */
+#line 1045 "awkgram.y" /* yacc.c:1646 */
{
char *arr = (yyvsp[-2])->lextok;
@@ -2870,11 +2871,11 @@ regular_print:
(yyval) = list_append(list_append((yyvsp[0]), (yyvsp[-2])), (yyvsp[-3]));
}
}
-#line 2874 "awkgram.c" /* yacc.c:1646 */
+#line 2875 "awkgram.c" /* yacc.c:1646 */
break;
case 64:
-#line 1081 "awkgram.y" /* yacc.c:1646 */
+#line 1082 "awkgram.y" /* yacc.c:1646 */
{
static bool warned = false;
char *arr = (yyvsp[-1])->lextok;
@@ -2900,52 +2901,52 @@ regular_print:
fatal(_("`delete' is not allowed with FUNCTAB"));
}
}
-#line 2904 "awkgram.c" /* yacc.c:1646 */
+#line 2905 "awkgram.c" /* yacc.c:1646 */
break;
case 65:
-#line 1107 "awkgram.y" /* yacc.c:1646 */
+#line 1108 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = optimize_assignment((yyvsp[0])); }
-#line 2910 "awkgram.c" /* yacc.c:1646 */
+#line 2911 "awkgram.c" /* yacc.c:1646 */
break;
case 66:
-#line 1112 "awkgram.y" /* yacc.c:1646 */
+#line 1113 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 2916 "awkgram.c" /* yacc.c:1646 */
+#line 2917 "awkgram.c" /* yacc.c:1646 */
break;
case 67:
-#line 1114 "awkgram.y" /* yacc.c:1646 */
+#line 1115 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 2922 "awkgram.c" /* yacc.c:1646 */
+#line 2923 "awkgram.c" /* yacc.c:1646 */
break;
case 68:
-#line 1119 "awkgram.y" /* yacc.c:1646 */
+#line 1120 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 2928 "awkgram.c" /* yacc.c:1646 */
+#line 2929 "awkgram.c" /* yacc.c:1646 */
break;
case 69:
-#line 1121 "awkgram.y" /* yacc.c:1646 */
+#line 1122 "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 2940 "awkgram.c" /* yacc.c:1646 */
break;
case 70:
-#line 1128 "awkgram.y" /* yacc.c:1646 */
+#line 1129 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 2945 "awkgram.c" /* yacc.c:1646 */
+#line 2946 "awkgram.c" /* yacc.c:1646 */
break;
case 71:
-#line 1133 "awkgram.y" /* yacc.c:1646 */
+#line 1134 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *casestmt = (yyvsp[0]);
if ((yyvsp[0]) == NULL)
@@ -2957,11 +2958,11 @@ regular_print:
bcfree((yyvsp[-2]));
(yyval) = (yyvsp[-4]);
}
-#line 2961 "awkgram.c" /* yacc.c:1646 */
+#line 2962 "awkgram.c" /* yacc.c:1646 */
break;
case 72:
-#line 1145 "awkgram.y" /* yacc.c:1646 */
+#line 1146 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *casestmt = (yyvsp[0]);
if ((yyvsp[0]) == NULL)
@@ -2972,17 +2973,17 @@ regular_print:
(yyvsp[-3])->case_stmt = casestmt;
(yyval) = (yyvsp[-3]);
}
-#line 2976 "awkgram.c" /* yacc.c:1646 */
+#line 2977 "awkgram.c" /* yacc.c:1646 */
break;
case 73:
-#line 1159 "awkgram.y" /* yacc.c:1646 */
+#line 1160 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 2982 "awkgram.c" /* yacc.c:1646 */
+#line 2983 "awkgram.c" /* yacc.c:1646 */
break;
case 74:
-#line 1161 "awkgram.y" /* yacc.c:1646 */
+#line 1162 "awkgram.y" /* yacc.c:1646 */
{
NODE *n = (yyvsp[0])->memory;
(void) force_number(n);
@@ -2990,71 +2991,71 @@ regular_print:
bcfree((yyvsp[-1]));
(yyval) = (yyvsp[0]);
}
-#line 2994 "awkgram.c" /* yacc.c:1646 */
+#line 2995 "awkgram.c" /* yacc.c:1646 */
break;
case 75:
-#line 1169 "awkgram.y" /* yacc.c:1646 */
+#line 1170 "awkgram.y" /* yacc.c:1646 */
{
bcfree((yyvsp[-1]));
(yyval) = (yyvsp[0]);
}
-#line 3003 "awkgram.c" /* yacc.c:1646 */
+#line 3004 "awkgram.c" /* yacc.c:1646 */
break;
case 76:
-#line 1174 "awkgram.y" /* yacc.c:1646 */
+#line 1175 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3009 "awkgram.c" /* yacc.c:1646 */
+#line 3010 "awkgram.c" /* yacc.c:1646 */
break;
case 77:
-#line 1176 "awkgram.y" /* yacc.c:1646 */
+#line 1177 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[0])->opcode = Op_push_re;
(yyval) = (yyvsp[0]);
}
-#line 3018 "awkgram.c" /* yacc.c:1646 */
+#line 3019 "awkgram.c" /* yacc.c:1646 */
break;
case 78:
-#line 1184 "awkgram.y" /* yacc.c:1646 */
+#line 1185 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3024 "awkgram.c" /* yacc.c:1646 */
+#line 3025 "awkgram.c" /* yacc.c:1646 */
break;
case 79:
-#line 1186 "awkgram.y" /* yacc.c:1646 */
+#line 1187 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3030 "awkgram.c" /* yacc.c:1646 */
+#line 3031 "awkgram.c" /* yacc.c:1646 */
break;
case 81:
-#line 1196 "awkgram.y" /* yacc.c:1646 */
+#line 1197 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = (yyvsp[-1]);
}
-#line 3038 "awkgram.c" /* yacc.c:1646 */
+#line 3039 "awkgram.c" /* yacc.c:1646 */
break;
case 82:
-#line 1203 "awkgram.y" /* yacc.c:1646 */
+#line 1204 "awkgram.y" /* yacc.c:1646 */
{
in_print = false;
in_parens = 0;
(yyval) = NULL;
}
-#line 3048 "awkgram.c" /* yacc.c:1646 */
+#line 3049 "awkgram.c" /* yacc.c:1646 */
break;
case 83:
-#line 1208 "awkgram.y" /* yacc.c:1646 */
+#line 1209 "awkgram.y" /* yacc.c:1646 */
{ in_print = false; in_parens = 0; }
-#line 3054 "awkgram.c" /* yacc.c:1646 */
+#line 3055 "awkgram.c" /* yacc.c:1646 */
break;
case 84:
-#line 1209 "awkgram.y" /* yacc.c:1646 */
+#line 1210 "awkgram.y" /* yacc.c:1646 */
{
if ((yyvsp[-2])->redir_type == redirect_twoway
&& (yyvsp[0])->lasti->opcode == Op_K_getline_redir
@@ -3062,136 +3063,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 3067 "awkgram.c" /* yacc.c:1646 */
break;
case 85:
-#line 1220 "awkgram.y" /* yacc.c:1646 */
+#line 1221 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = mk_condition((yyvsp[-3]), (yyvsp[-5]), (yyvsp[0]), NULL, NULL);
}
-#line 3074 "awkgram.c" /* yacc.c:1646 */
+#line 3075 "awkgram.c" /* yacc.c:1646 */
break;
case 86:
-#line 1225 "awkgram.y" /* yacc.c:1646 */
+#line 1226 "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 3083 "awkgram.c" /* yacc.c:1646 */
break;
case 91:
-#line 1242 "awkgram.y" /* yacc.c:1646 */
+#line 1243 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3088 "awkgram.c" /* yacc.c:1646 */
+#line 3089 "awkgram.c" /* yacc.c:1646 */
break;
case 92:
-#line 1244 "awkgram.y" /* yacc.c:1646 */
+#line 1245 "awkgram.y" /* yacc.c:1646 */
{
bcfree((yyvsp[-1]));
(yyval) = (yyvsp[0]);
}
-#line 3097 "awkgram.c" /* yacc.c:1646 */
+#line 3098 "awkgram.c" /* yacc.c:1646 */
break;
case 93:
-#line 1252 "awkgram.y" /* yacc.c:1646 */
+#line 1253 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3103 "awkgram.c" /* yacc.c:1646 */
+#line 3104 "awkgram.c" /* yacc.c:1646 */
break;
case 94:
-#line 1254 "awkgram.y" /* yacc.c:1646 */
+#line 1255 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3109 "awkgram.c" /* yacc.c:1646 */
+#line 3110 "awkgram.c" /* yacc.c:1646 */
break;
case 95:
-#line 1259 "awkgram.y" /* yacc.c:1646 */
+#line 1260 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[0])->param_count = 0;
(yyval) = list_create((yyvsp[0]));
}
-#line 3118 "awkgram.c" /* yacc.c:1646 */
+#line 3119 "awkgram.c" /* yacc.c:1646 */
break;
case 96:
-#line 1264 "awkgram.y" /* yacc.c:1646 */
+#line 1265 "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 3129 "awkgram.c" /* yacc.c:1646 */
break;
case 97:
-#line 1270 "awkgram.y" /* yacc.c:1646 */
+#line 1271 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3134 "awkgram.c" /* yacc.c:1646 */
+#line 3135 "awkgram.c" /* yacc.c:1646 */
break;
case 98:
-#line 1272 "awkgram.y" /* yacc.c:1646 */
+#line 1273 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[-1]); }
-#line 3140 "awkgram.c" /* yacc.c:1646 */
+#line 3141 "awkgram.c" /* yacc.c:1646 */
break;
case 99:
-#line 1274 "awkgram.y" /* yacc.c:1646 */
+#line 1275 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[-2]); }
-#line 3146 "awkgram.c" /* yacc.c:1646 */
+#line 3147 "awkgram.c" /* yacc.c:1646 */
break;
case 100:
-#line 1280 "awkgram.y" /* yacc.c:1646 */
+#line 1281 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3152 "awkgram.c" /* yacc.c:1646 */
+#line 3153 "awkgram.c" /* yacc.c:1646 */
break;
case 101:
-#line 1282 "awkgram.y" /* yacc.c:1646 */
+#line 1283 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3158 "awkgram.c" /* yacc.c:1646 */
+#line 3159 "awkgram.c" /* yacc.c:1646 */
break;
case 102:
-#line 1287 "awkgram.y" /* yacc.c:1646 */
+#line 1288 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3164 "awkgram.c" /* yacc.c:1646 */
+#line 3165 "awkgram.c" /* yacc.c:1646 */
break;
case 103:
-#line 1289 "awkgram.y" /* yacc.c:1646 */
+#line 1290 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3170 "awkgram.c" /* yacc.c:1646 */
+#line 3171 "awkgram.c" /* yacc.c:1646 */
break;
case 104:
-#line 1294 "awkgram.y" /* yacc.c:1646 */
+#line 1295 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_expression_list(NULL, (yyvsp[0])); }
-#line 3176 "awkgram.c" /* yacc.c:1646 */
+#line 3177 "awkgram.c" /* yacc.c:1646 */
break;
case 105:
-#line 1296 "awkgram.y" /* yacc.c:1646 */
+#line 1297 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0]));
yyerrok;
}
-#line 3185 "awkgram.c" /* yacc.c:1646 */
+#line 3186 "awkgram.c" /* yacc.c:1646 */
break;
case 106:
-#line 1301 "awkgram.y" /* yacc.c:1646 */
+#line 1302 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3191 "awkgram.c" /* yacc.c:1646 */
+#line 3192 "awkgram.c" /* yacc.c:1646 */
break;
case 107:
-#line 1303 "awkgram.y" /* yacc.c:1646 */
+#line 1304 "awkgram.y" /* yacc.c:1646 */
{
/*
* Returning the expression list instead of NULL lets
@@ -3199,52 +3200,52 @@ regular_print:
*/
(yyval) = (yyvsp[-1]);
}
-#line 3203 "awkgram.c" /* yacc.c:1646 */
+#line 3204 "awkgram.c" /* yacc.c:1646 */
break;
case 108:
-#line 1311 "awkgram.y" /* yacc.c:1646 */
+#line 1312 "awkgram.y" /* yacc.c:1646 */
{
/* Ditto */
(yyval) = mk_expression_list((yyvsp[-2]), (yyvsp[0]));
}
-#line 3212 "awkgram.c" /* yacc.c:1646 */
+#line 3213 "awkgram.c" /* yacc.c:1646 */
break;
case 109:
-#line 1316 "awkgram.y" /* yacc.c:1646 */
+#line 1317 "awkgram.y" /* yacc.c:1646 */
{
/* Ditto */
(yyval) = (yyvsp[-2]);
}
-#line 3221 "awkgram.c" /* yacc.c:1646 */
+#line 3222 "awkgram.c" /* yacc.c:1646 */
break;
case 110:
-#line 1325 "awkgram.y" /* yacc.c:1646 */
+#line 1326 "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 3233 "awkgram.c" /* yacc.c:1646 */
break;
case 111:
-#line 1332 "awkgram.y" /* yacc.c:1646 */
+#line 1333 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3238 "awkgram.c" /* yacc.c:1646 */
+#line 3239 "awkgram.c" /* yacc.c:1646 */
break;
case 112:
-#line 1334 "awkgram.y" /* yacc.c:1646 */
+#line 1335 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_boolean((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3244 "awkgram.c" /* yacc.c:1646 */
+#line 3245 "awkgram.c" /* yacc.c:1646 */
break;
case 113:
-#line 1336 "awkgram.y" /* yacc.c:1646 */
+#line 1337 "awkgram.y" /* yacc.c:1646 */
{
if ((yyvsp[-2])->lasti->opcode == Op_match_rec)
warning_ln((yyvsp[-1])->source_line,
@@ -3260,11 +3261,11 @@ regular_print:
(yyval) = list_append(list_merge((yyvsp[-2]), (yyvsp[0])), (yyvsp[-1]));
}
}
-#line 3264 "awkgram.c" /* yacc.c:1646 */
+#line 3265 "awkgram.c" /* yacc.c:1646 */
break;
case 114:
-#line 1352 "awkgram.y" /* yacc.c:1646 */
+#line 1353 "awkgram.y" /* yacc.c:1646 */
{
if (do_lint_old)
warning_ln((yyvsp[-1])->source_line,
@@ -3274,91 +3275,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 3279 "awkgram.c" /* yacc.c:1646 */
break;
case 115:
-#line 1362 "awkgram.y" /* yacc.c:1646 */
+#line 1363 "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 3290 "awkgram.c" /* yacc.c:1646 */
break;
case 116:
-#line 1369 "awkgram.y" /* yacc.c:1646 */
+#line 1370 "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 3296 "awkgram.c" /* yacc.c:1646 */
break;
case 117:
-#line 1371 "awkgram.y" /* yacc.c:1646 */
+#line 1372 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3301 "awkgram.c" /* yacc.c:1646 */
+#line 3302 "awkgram.c" /* yacc.c:1646 */
break;
case 118:
-#line 1376 "awkgram.y" /* yacc.c:1646 */
+#line 1377 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3307 "awkgram.c" /* yacc.c:1646 */
+#line 3308 "awkgram.c" /* yacc.c:1646 */
break;
case 119:
-#line 1378 "awkgram.y" /* yacc.c:1646 */
+#line 1379 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3313 "awkgram.c" /* yacc.c:1646 */
+#line 3314 "awkgram.c" /* yacc.c:1646 */
break;
case 120:
-#line 1380 "awkgram.y" /* yacc.c:1646 */
+#line 1381 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[0])->opcode = Op_assign_quotient;
(yyval) = (yyvsp[0]);
}
-#line 3322 "awkgram.c" /* yacc.c:1646 */
+#line 3323 "awkgram.c" /* yacc.c:1646 */
break;
case 121:
-#line 1388 "awkgram.y" /* yacc.c:1646 */
+#line 1389 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3328 "awkgram.c" /* yacc.c:1646 */
+#line 3329 "awkgram.c" /* yacc.c:1646 */
break;
case 122:
-#line 1390 "awkgram.y" /* yacc.c:1646 */
+#line 1391 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3334 "awkgram.c" /* yacc.c:1646 */
+#line 3335 "awkgram.c" /* yacc.c:1646 */
break;
case 123:
-#line 1395 "awkgram.y" /* yacc.c:1646 */
+#line 1396 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3340 "awkgram.c" /* yacc.c:1646 */
+#line 3341 "awkgram.c" /* yacc.c:1646 */
break;
case 124:
-#line 1397 "awkgram.y" /* yacc.c:1646 */
+#line 1398 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3346 "awkgram.c" /* yacc.c:1646 */
+#line 3347 "awkgram.c" /* yacc.c:1646 */
break;
case 125:
-#line 1402 "awkgram.y" /* yacc.c:1646 */
+#line 1403 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3352 "awkgram.c" /* yacc.c:1646 */
+#line 3353 "awkgram.c" /* yacc.c:1646 */
break;
case 126:
-#line 1404 "awkgram.y" /* yacc.c:1646 */
+#line 1405 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3358 "awkgram.c" /* yacc.c:1646 */
+#line 3359 "awkgram.c" /* yacc.c:1646 */
break;
case 127:
-#line 1406 "awkgram.y" /* yacc.c:1646 */
+#line 1407 "awkgram.y" /* yacc.c:1646 */
{
int count = 2;
bool is_simple_var = false;
@@ -3405,47 +3406,47 @@ regular_print:
max_args = count;
}
}
-#line 3409 "awkgram.c" /* yacc.c:1646 */
+#line 3410 "awkgram.c" /* yacc.c:1646 */
break;
case 129:
-#line 1458 "awkgram.y" /* yacc.c:1646 */
+#line 1459 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3415 "awkgram.c" /* yacc.c:1646 */
+#line 3416 "awkgram.c" /* yacc.c:1646 */
break;
case 130:
-#line 1460 "awkgram.y" /* yacc.c:1646 */
+#line 1461 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3421 "awkgram.c" /* yacc.c:1646 */
+#line 3422 "awkgram.c" /* yacc.c:1646 */
break;
case 131:
-#line 1462 "awkgram.y" /* yacc.c:1646 */
+#line 1463 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3427 "awkgram.c" /* yacc.c:1646 */
+#line 3428 "awkgram.c" /* yacc.c:1646 */
break;
case 132:
-#line 1464 "awkgram.y" /* yacc.c:1646 */
+#line 1465 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3433 "awkgram.c" /* yacc.c:1646 */
+#line 3434 "awkgram.c" /* yacc.c:1646 */
break;
case 133:
-#line 1466 "awkgram.y" /* yacc.c:1646 */
+#line 1467 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3439 "awkgram.c" /* yacc.c:1646 */
+#line 3440 "awkgram.c" /* yacc.c:1646 */
break;
case 134:
-#line 1468 "awkgram.y" /* yacc.c:1646 */
+#line 1469 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3445 "awkgram.c" /* yacc.c:1646 */
+#line 3446 "awkgram.c" /* yacc.c:1646 */
break;
case 135:
-#line 1470 "awkgram.y" /* yacc.c:1646 */
+#line 1471 "awkgram.y" /* yacc.c:1646 */
{
/*
* In BEGINFILE/ENDFILE, allow `getline [var] < file'
@@ -3459,29 +3460,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 3464 "awkgram.c" /* yacc.c:1646 */
break;
case 136:
-#line 1484 "awkgram.y" /* yacc.c:1646 */
+#line 1485 "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 3473 "awkgram.c" /* yacc.c:1646 */
break;
case 137:
-#line 1489 "awkgram.y" /* yacc.c:1646 */
+#line 1490 "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 3482 "awkgram.c" /* yacc.c:1646 */
break;
case 138:
-#line 1494 "awkgram.y" /* yacc.c:1646 */
+#line 1495 "awkgram.y" /* yacc.c:1646 */
{
if (do_lint_old) {
warning_ln((yyvsp[-1])->source_line,
@@ -3501,64 +3502,64 @@ regular_print:
(yyval) = list_append(list_merge(t, (yyvsp[0])), (yyvsp[-1]));
}
}
-#line 3505 "awkgram.c" /* yacc.c:1646 */
+#line 3506 "awkgram.c" /* yacc.c:1646 */
break;
case 139:
-#line 1519 "awkgram.y" /* yacc.c:1646 */
+#line 1520 "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 3515 "awkgram.c" /* yacc.c:1646 */
break;
case 140:
-#line 1525 "awkgram.y" /* yacc.c:1646 */
+#line 1526 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3520 "awkgram.c" /* yacc.c:1646 */
+#line 3521 "awkgram.c" /* yacc.c:1646 */
break;
case 141:
-#line 1527 "awkgram.y" /* yacc.c:1646 */
+#line 1528 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3526 "awkgram.c" /* yacc.c:1646 */
+#line 3527 "awkgram.c" /* yacc.c:1646 */
break;
case 142:
-#line 1529 "awkgram.y" /* yacc.c:1646 */
+#line 1530 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3532 "awkgram.c" /* yacc.c:1646 */
+#line 3533 "awkgram.c" /* yacc.c:1646 */
break;
case 143:
-#line 1531 "awkgram.y" /* yacc.c:1646 */
+#line 1532 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3538 "awkgram.c" /* yacc.c:1646 */
+#line 3539 "awkgram.c" /* yacc.c:1646 */
break;
case 144:
-#line 1533 "awkgram.y" /* yacc.c:1646 */
+#line 1534 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3544 "awkgram.c" /* yacc.c:1646 */
+#line 3545 "awkgram.c" /* yacc.c:1646 */
break;
case 145:
-#line 1535 "awkgram.y" /* yacc.c:1646 */
+#line 1536 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = mk_binary((yyvsp[-2]), (yyvsp[0]), (yyvsp[-1])); }
-#line 3550 "awkgram.c" /* yacc.c:1646 */
+#line 3551 "awkgram.c" /* yacc.c:1646 */
break;
case 146:
-#line 1540 "awkgram.y" /* yacc.c:1646 */
+#line 1541 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = list_create((yyvsp[0]));
}
-#line 3558 "awkgram.c" /* yacc.c:1646 */
+#line 3559 "awkgram.c" /* yacc.c:1646 */
break;
case 147:
-#line 1544 "awkgram.y" /* yacc.c:1646 */
+#line 1545 "awkgram.y" /* yacc.c:1646 */
{
if ((yyvsp[0])->opcode == Op_match_rec) {
(yyvsp[0])->opcode = Op_nomatch;
@@ -3590,37 +3591,37 @@ regular_print:
}
}
}
-#line 3594 "awkgram.c" /* yacc.c:1646 */
+#line 3595 "awkgram.c" /* yacc.c:1646 */
break;
case 148:
-#line 1576 "awkgram.y" /* yacc.c:1646 */
+#line 1577 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[-1]); }
-#line 3600 "awkgram.c" /* yacc.c:1646 */
+#line 3601 "awkgram.c" /* yacc.c:1646 */
break;
case 149:
-#line 1578 "awkgram.y" /* yacc.c:1646 */
+#line 1579 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = snode((yyvsp[-1]), (yyvsp[-3]));
if ((yyval) == NULL)
YYABORT;
}
-#line 3610 "awkgram.c" /* yacc.c:1646 */
+#line 3611 "awkgram.c" /* yacc.c:1646 */
break;
case 150:
-#line 1584 "awkgram.y" /* yacc.c:1646 */
+#line 1585 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = snode((yyvsp[-1]), (yyvsp[-3]));
if ((yyval) == NULL)
YYABORT;
}
-#line 3620 "awkgram.c" /* yacc.c:1646 */
+#line 3621 "awkgram.c" /* yacc.c:1646 */
break;
case 151:
-#line 1590 "awkgram.y" /* yacc.c:1646 */
+#line 1591 "awkgram.y" /* yacc.c:1646 */
{
static bool warned = false;
@@ -3633,45 +3634,45 @@ regular_print:
if ((yyval) == NULL)
YYABORT;
}
-#line 3637 "awkgram.c" /* yacc.c:1646 */
+#line 3638 "awkgram.c" /* yacc.c:1646 */
break;
case 154:
-#line 1605 "awkgram.y" /* yacc.c:1646 */
+#line 1606 "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 3647 "awkgram.c" /* yacc.c:1646 */
break;
case 155:
-#line 1610 "awkgram.y" /* yacc.c:1646 */
+#line 1611 "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 3656 "awkgram.c" /* yacc.c:1646 */
break;
case 156:
-#line 1615 "awkgram.y" /* yacc.c:1646 */
+#line 1616 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = list_create((yyvsp[0]));
}
-#line 3663 "awkgram.c" /* yacc.c:1646 */
+#line 3664 "awkgram.c" /* yacc.c:1646 */
break;
case 157:
-#line 1619 "awkgram.y" /* yacc.c:1646 */
+#line 1620 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = list_create((yyvsp[0]));
}
-#line 3671 "awkgram.c" /* yacc.c:1646 */
+#line 3672 "awkgram.c" /* yacc.c:1646 */
break;
case 158:
-#line 1623 "awkgram.y" /* yacc.c:1646 */
+#line 1624 "awkgram.y" /* yacc.c:1646 */
{
if ((yyvsp[0])->lasti->opcode == Op_push_i
&& ((yyvsp[0])->lasti->memory->flags & (STRCUR|STRING)) == 0
@@ -3686,11 +3687,11 @@ regular_print:
(yyval) = list_append((yyvsp[0]), (yyvsp[-1]));
}
}
-#line 3690 "awkgram.c" /* yacc.c:1646 */
+#line 3691 "awkgram.c" /* yacc.c:1646 */
break;
case 159:
-#line 1638 "awkgram.y" /* yacc.c:1646 */
+#line 1639 "awkgram.y" /* yacc.c:1646 */
{
/*
* was: $$ = $2
@@ -3700,20 +3701,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 3705 "awkgram.c" /* yacc.c:1646 */
break;
case 160:
-#line 1651 "awkgram.y" /* yacc.c:1646 */
+#line 1652 "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 3714 "awkgram.c" /* yacc.c:1646 */
break;
case 161:
-#line 1656 "awkgram.y" /* yacc.c:1646 */
+#line 1657 "awkgram.y" /* yacc.c:1646 */
{
/* indirect function call */
INSTRUCTION *f, *t;
@@ -3746,11 +3747,11 @@ regular_print:
(yyval) = list_prepend((yyvsp[0]), t);
}
-#line 3750 "awkgram.c" /* yacc.c:1646 */
+#line 3751 "awkgram.c" /* yacc.c:1646 */
break;
case 162:
-#line 1692 "awkgram.y" /* yacc.c:1646 */
+#line 1693 "awkgram.y" /* yacc.c:1646 */
{
param_sanity((yyvsp[-1]));
(yyvsp[-3])->opcode = Op_func_call;
@@ -3764,49 +3765,49 @@ regular_print:
(yyval) = list_append(t, (yyvsp[-3]));
}
}
-#line 3768 "awkgram.c" /* yacc.c:1646 */
+#line 3769 "awkgram.c" /* yacc.c:1646 */
break;
case 163:
-#line 1709 "awkgram.y" /* yacc.c:1646 */
+#line 1710 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3774 "awkgram.c" /* yacc.c:1646 */
+#line 3775 "awkgram.c" /* yacc.c:1646 */
break;
case 164:
-#line 1711 "awkgram.y" /* yacc.c:1646 */
+#line 1712 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3780 "awkgram.c" /* yacc.c:1646 */
+#line 3781 "awkgram.c" /* yacc.c:1646 */
break;
case 165:
-#line 1716 "awkgram.y" /* yacc.c:1646 */
+#line 1717 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3786 "awkgram.c" /* yacc.c:1646 */
+#line 3787 "awkgram.c" /* yacc.c:1646 */
break;
case 166:
-#line 1718 "awkgram.y" /* yacc.c:1646 */
+#line 1719 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[-1]); }
-#line 3792 "awkgram.c" /* yacc.c:1646 */
+#line 3793 "awkgram.c" /* yacc.c:1646 */
break;
case 167:
-#line 1723 "awkgram.y" /* yacc.c:1646 */
+#line 1724 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3798 "awkgram.c" /* yacc.c:1646 */
+#line 3799 "awkgram.c" /* yacc.c:1646 */
break;
case 168:
-#line 1725 "awkgram.y" /* yacc.c:1646 */
+#line 1726 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = list_merge((yyvsp[-1]), (yyvsp[0]));
}
-#line 3806 "awkgram.c" /* yacc.c:1646 */
+#line 3807 "awkgram.c" /* yacc.c:1646 */
break;
case 169:
-#line 1732 "awkgram.y" /* yacc.c:1646 */
+#line 1733 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *ip = (yyvsp[0])->lasti;
int count = ip->sub_count; /* # of SUBSEP-seperated expressions */
@@ -3820,11 +3821,11 @@ regular_print:
sub_counter++; /* count # of dimensions */
(yyval) = (yyvsp[0]);
}
-#line 3824 "awkgram.c" /* yacc.c:1646 */
+#line 3825 "awkgram.c" /* yacc.c:1646 */
break;
case 170:
-#line 1749 "awkgram.y" /* yacc.c:1646 */
+#line 1750 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *t = (yyvsp[-1]);
if ((yyvsp[-1]) == NULL) {
@@ -3838,31 +3839,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 3843 "awkgram.c" /* yacc.c:1646 */
break;
case 171:
-#line 1766 "awkgram.y" /* yacc.c:1646 */
+#line 1767 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); }
-#line 3848 "awkgram.c" /* yacc.c:1646 */
+#line 3849 "awkgram.c" /* yacc.c:1646 */
break;
case 172:
-#line 1768 "awkgram.y" /* yacc.c:1646 */
+#line 1769 "awkgram.y" /* yacc.c:1646 */
{
(yyval) = list_merge((yyvsp[-1]), (yyvsp[0]));
}
-#line 3856 "awkgram.c" /* yacc.c:1646 */
+#line 3857 "awkgram.c" /* yacc.c:1646 */
break;
case 173:
-#line 1775 "awkgram.y" /* yacc.c:1646 */
+#line 1776 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[-1]); }
-#line 3862 "awkgram.c" /* yacc.c:1646 */
+#line 3863 "awkgram.c" /* yacc.c:1646 */
break;
case 174:
-#line 1780 "awkgram.y" /* yacc.c:1646 */
+#line 1781 "awkgram.y" /* yacc.c:1646 */
{
char *var_name = (yyvsp[0])->lextok;
@@ -3870,22 +3871,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 3875 "awkgram.c" /* yacc.c:1646 */
break;
case 175:
-#line 1788 "awkgram.y" /* yacc.c:1646 */
+#line 1789 "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 3886 "awkgram.c" /* yacc.c:1646 */
break;
case 176:
-#line 1798 "awkgram.y" /* yacc.c:1646 */
+#line 1799 "awkgram.y" /* yacc.c:1646 */
{
INSTRUCTION *ip = (yyvsp[0])->nexti;
if (ip->opcode == Op_push
@@ -3897,73 +3898,73 @@ regular_print:
} else
(yyval) = (yyvsp[0]);
}
-#line 3901 "awkgram.c" /* yacc.c:1646 */
+#line 3902 "awkgram.c" /* yacc.c:1646 */
break;
case 177:
-#line 1810 "awkgram.y" /* yacc.c:1646 */
+#line 1811 "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 3912 "awkgram.c" /* yacc.c:1646 */
break;
case 178:
-#line 1819 "awkgram.y" /* yacc.c:1646 */
+#line 1820 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[0])->opcode = Op_postincrement;
}
-#line 3919 "awkgram.c" /* yacc.c:1646 */
+#line 3920 "awkgram.c" /* yacc.c:1646 */
break;
case 179:
-#line 1823 "awkgram.y" /* yacc.c:1646 */
+#line 1824 "awkgram.y" /* yacc.c:1646 */
{
(yyvsp[0])->opcode = Op_postdecrement;
}
-#line 3927 "awkgram.c" /* yacc.c:1646 */
+#line 3928 "awkgram.c" /* yacc.c:1646 */
break;
case 180:
-#line 1826 "awkgram.y" /* yacc.c:1646 */
+#line 1827 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = NULL; }
-#line 3933 "awkgram.c" /* yacc.c:1646 */
+#line 3934 "awkgram.c" /* yacc.c:1646 */
break;
case 182:
-#line 1834 "awkgram.y" /* yacc.c:1646 */
+#line 1835 "awkgram.y" /* yacc.c:1646 */
{ yyerrok; }
-#line 3939 "awkgram.c" /* yacc.c:1646 */
+#line 3940 "awkgram.c" /* yacc.c:1646 */
break;
case 183:
-#line 1838 "awkgram.y" /* yacc.c:1646 */
+#line 1839 "awkgram.y" /* yacc.c:1646 */
{ yyerrok; }
-#line 3945 "awkgram.c" /* yacc.c:1646 */
+#line 3946 "awkgram.c" /* yacc.c:1646 */
break;
case 186:
-#line 1847 "awkgram.y" /* yacc.c:1646 */
+#line 1848 "awkgram.y" /* yacc.c:1646 */
{ yyerrok; }
-#line 3951 "awkgram.c" /* yacc.c:1646 */
+#line 3952 "awkgram.c" /* yacc.c:1646 */
break;
case 187:
-#line 1851 "awkgram.y" /* yacc.c:1646 */
+#line 1852 "awkgram.y" /* yacc.c:1646 */
{ (yyval) = (yyvsp[0]); yyerrok; }
-#line 3957 "awkgram.c" /* yacc.c:1646 */
+#line 3958 "awkgram.c" /* yacc.c:1646 */
break;
case 188:
-#line 1855 "awkgram.y" /* yacc.c:1646 */
+#line 1856 "awkgram.y" /* yacc.c:1646 */
{ yyerrok; }
-#line 3963 "awkgram.c" /* yacc.c:1646 */
+#line 3964 "awkgram.c" /* yacc.c:1646 */
break;
-#line 3967 "awkgram.c" /* yacc.c:1646 */
+#line 3968 "awkgram.c" /* yacc.c:1646 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@@ -4191,7 +4192,7 @@ yyreturn:
#endif
return yyresult;
}
-#line 1857 "awkgram.y" /* yacc.c:1906 */
+#line 1858 "awkgram.y" /* yacc.c:1906 */
struct token {
@@ -4703,7 +4704,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;
diff --git a/awkgram.y b/awkgram.y
index 64ed3c56..49eb585c 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -146,6 +146,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;
@@ -2365,7 +2366,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;
diff --git a/configh.in b/configh.in
index 301fa21a..7e001f8e 100644
--- a/configh.in
+++ b/configh.in
@@ -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
diff --git a/configure b/configure
index 8d5968ad..b5f485ca 100755
--- a/configure
+++ b/configure
@@ -10011,9 +10011,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 a8711c5a..70074139 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
diff --git a/eval.c b/eval.c
index a9ff3b52..e7a346d3 100644
--- a/eval.c
+++ b/eval.c
@@ -1027,6 +1027,7 @@ update_ERRNO_int(int errcode)
{
char *cp;
+ update_PROCINFO_num("errno", errcode);
if (errcode) {
cp = strerror(errcode);
cp = gettext(cp);
@@ -1041,6 +1042,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));
}
@@ -1050,6 +1052,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 3fee967f..82ae5b69 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -158,6 +158,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/Makefile.am b/extension/Makefile.am
index e6678c54..c8b1f53c 100644
--- a/extension/Makefile.am
+++ b/extension/Makefile.am
@@ -35,6 +35,7 @@ RM = rm -f
# Note: rwarray does not currently compile.
pkgextension_LTLIBRARIES = \
+ errno.la \
filefuncs.la \
fnmatch.la \
fork.la \
@@ -45,6 +46,7 @@ pkgextension_LTLIBRARIES = \
revoutput.la \
revtwoway.la \
rwarray.la \
+ select.la \
testext.la \
time.la
@@ -52,6 +54,10 @@ MY_MODULE_FLAGS = -module -avoid-version -no-undefined
# on Cygwin, gettext requires that we link with -lintl
MY_LIBS = $(LTLIBINTL)
+errno_la_SOURCES = errno.c
+errno_la_LDFLAGS = $(MY_MODULE_FLAGS)
+errno_la_LIBADD = $(MY_LIBS)
+
filefuncs_la_SOURCES = filefuncs.c stack.h stack.c gawkfts.h \
gawkfts.c gawkdirfd.h
filefuncs_la_LDFLAGS = $(MY_MODULE_FLAGS)
@@ -93,6 +99,10 @@ rwarray_la_SOURCES = rwarray.c
rwarray_la_LDFLAGS = $(MY_MODULE_FLAGS)
rwarray_la_LIBADD = $(MY_LIBS)
+select_la_SOURCES = select.c
+select_la_LDFLAGS = $(MY_MODULE_FLAGS)
+select_la_LIBADD = $(MY_LIBS)
+
time_la_SOURCES = time.c
time_la_LDFLAGS = $(MY_MODULE_FLAGS)
time_la_LIBADD = $(MY_LIBS)
@@ -115,8 +125,10 @@ uninstall-recursive: uninstall-so
EXTRA_DIST = build-aux/config.rpath \
ChangeLog \
ChangeLog.0 \
+ errlist.h \
fts.3 \
- README.fts
+ README.fts \
+ siglist.h
dist_man_MANS = \
filefuncs.3am fnmatch.3am fork.3am inplace.3am \
diff --git a/extension/Makefile.in b/extension/Makefile.in
index 46168e4e..821d6112 100644
--- a/extension/Makefile.in
+++ b/extension/Makefile.in
@@ -167,13 +167,19 @@ am__installdirs = "$(DESTDIR)$(pkgextensiondir)" \
LTLIBRARIES = $(pkgextension_LTLIBRARIES)
am__DEPENDENCIES_1 =
am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
-filefuncs_la_DEPENDENCIES = $(am__DEPENDENCIES_2)
-am_filefuncs_la_OBJECTS = filefuncs.lo stack.lo gawkfts.lo
-filefuncs_la_OBJECTS = $(am_filefuncs_la_OBJECTS)
+errno_la_DEPENDENCIES = $(am__DEPENDENCIES_2)
+am_errno_la_OBJECTS = errno.lo
+errno_la_OBJECTS = $(am_errno_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
+errno_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(errno_la_LDFLAGS) $(LDFLAGS) -o $@
+filefuncs_la_DEPENDENCIES = $(am__DEPENDENCIES_2)
+am_filefuncs_la_OBJECTS = filefuncs.lo stack.lo gawkfts.lo
+filefuncs_la_OBJECTS = $(am_filefuncs_la_OBJECTS)
filefuncs_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(filefuncs_la_LDFLAGS) $(LDFLAGS) -o $@
@@ -231,6 +237,12 @@ rwarray_la_OBJECTS = $(am_rwarray_la_OBJECTS)
rwarray_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(rwarray_la_LDFLAGS) $(LDFLAGS) -o $@
+select_la_DEPENDENCIES = $(am__DEPENDENCIES_2)
+am_select_la_OBJECTS = select.lo
+select_la_OBJECTS = $(am_select_la_OBJECTS)
+select_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(select_la_LDFLAGS) $(LDFLAGS) -o $@
testext_la_DEPENDENCIES = $(am__DEPENDENCIES_2)
am_testext_la_OBJECTS = testext.lo
testext_la_OBJECTS = $(am_testext_la_OBJECTS)
@@ -277,16 +289,18 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
-SOURCES = $(filefuncs_la_SOURCES) $(fnmatch_la_SOURCES) \
- $(fork_la_SOURCES) $(inplace_la_SOURCES) $(ordchr_la_SOURCES) \
- $(readdir_la_SOURCES) $(readfile_la_SOURCES) \
- $(revoutput_la_SOURCES) $(revtwoway_la_SOURCES) \
- $(rwarray_la_SOURCES) $(testext_la_SOURCES) $(time_la_SOURCES)
-DIST_SOURCES = $(filefuncs_la_SOURCES) $(fnmatch_la_SOURCES) \
- $(fork_la_SOURCES) $(inplace_la_SOURCES) $(ordchr_la_SOURCES) \
- $(readdir_la_SOURCES) $(readfile_la_SOURCES) \
- $(revoutput_la_SOURCES) $(revtwoway_la_SOURCES) \
- $(rwarray_la_SOURCES) $(testext_la_SOURCES) $(time_la_SOURCES)
+SOURCES = $(errno_la_SOURCES) $(filefuncs_la_SOURCES) \
+ $(fnmatch_la_SOURCES) $(fork_la_SOURCES) $(inplace_la_SOURCES) \
+ $(ordchr_la_SOURCES) $(readdir_la_SOURCES) \
+ $(readfile_la_SOURCES) $(revoutput_la_SOURCES) \
+ $(revtwoway_la_SOURCES) $(rwarray_la_SOURCES) \
+ $(select_la_SOURCES) $(testext_la_SOURCES) $(time_la_SOURCES)
+DIST_SOURCES = $(errno_la_SOURCES) $(filefuncs_la_SOURCES) \
+ $(fnmatch_la_SOURCES) $(fork_la_SOURCES) $(inplace_la_SOURCES) \
+ $(ordchr_la_SOURCES) $(readdir_la_SOURCES) \
+ $(readfile_la_SOURCES) $(revoutput_la_SOURCES) \
+ $(revtwoway_la_SOURCES) $(rwarray_la_SOURCES) \
+ $(select_la_SOURCES) $(testext_la_SOURCES) $(time_la_SOURCES)
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
install-data-recursive install-dvi-recursive \
@@ -518,6 +532,7 @@ RM = rm -f
# Note: rwarray does not currently compile.
pkgextension_LTLIBRARIES = \
+ errno.la \
filefuncs.la \
fnmatch.la \
fork.la \
@@ -528,12 +543,16 @@ pkgextension_LTLIBRARIES = \
revoutput.la \
revtwoway.la \
rwarray.la \
+ select.la \
testext.la \
time.la
MY_MODULE_FLAGS = -module -avoid-version -no-undefined
# on Cygwin, gettext requires that we link with -lintl
MY_LIBS = $(LTLIBINTL)
+errno_la_SOURCES = errno.c
+errno_la_LDFLAGS = $(MY_MODULE_FLAGS)
+errno_la_LIBADD = $(MY_LIBS)
filefuncs_la_SOURCES = filefuncs.c stack.h stack.c gawkfts.h \
gawkfts.c gawkdirfd.h
@@ -566,6 +585,9 @@ revtwoway_la_LIBADD = $(MY_LIBS)
rwarray_la_SOURCES = rwarray.c
rwarray_la_LDFLAGS = $(MY_MODULE_FLAGS)
rwarray_la_LIBADD = $(MY_LIBS)
+select_la_SOURCES = select.c
+select_la_LDFLAGS = $(MY_MODULE_FLAGS)
+select_la_LIBADD = $(MY_LIBS)
time_la_SOURCES = time.c
time_la_LDFLAGS = $(MY_MODULE_FLAGS)
time_la_LIBADD = $(MY_LIBS)
@@ -575,8 +597,10 @@ testext_la_LIBADD = $(MY_LIBS)
EXTRA_DIST = build-aux/config.rpath \
ChangeLog \
ChangeLog.0 \
+ errlist.h \
fts.3 \
- README.fts
+ README.fts \
+ siglist.h
dist_man_MANS = \
filefuncs.3am fnmatch.3am fork.3am inplace.3am \
@@ -676,6 +700,9 @@ clean-pkgextensionLTLIBRARIES:
rm -f $${locs}; \
}
+errno.la: $(errno_la_OBJECTS) $(errno_la_DEPENDENCIES) $(EXTRA_errno_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(errno_la_LINK) -rpath $(pkgextensiondir) $(errno_la_OBJECTS) $(errno_la_LIBADD) $(LIBS)
+
filefuncs.la: $(filefuncs_la_OBJECTS) $(filefuncs_la_DEPENDENCIES) $(EXTRA_filefuncs_la_DEPENDENCIES)
$(AM_V_CCLD)$(filefuncs_la_LINK) -rpath $(pkgextensiondir) $(filefuncs_la_OBJECTS) $(filefuncs_la_LIBADD) $(LIBS)
@@ -706,6 +733,9 @@ revtwoway.la: $(revtwoway_la_OBJECTS) $(revtwoway_la_DEPENDENCIES) $(EXTRA_revtw
rwarray.la: $(rwarray_la_OBJECTS) $(rwarray_la_DEPENDENCIES) $(EXTRA_rwarray_la_DEPENDENCIES)
$(AM_V_CCLD)$(rwarray_la_LINK) -rpath $(pkgextensiondir) $(rwarray_la_OBJECTS) $(rwarray_la_LIBADD) $(LIBS)
+select.la: $(select_la_OBJECTS) $(select_la_DEPENDENCIES) $(EXTRA_select_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(select_la_LINK) -rpath $(pkgextensiondir) $(select_la_OBJECTS) $(select_la_LIBADD) $(LIBS)
+
testext.la: $(testext_la_OBJECTS) $(testext_la_DEPENDENCIES) $(EXTRA_testext_la_DEPENDENCIES)
$(AM_V_CCLD)$(testext_la_LINK) -rpath $(pkgextensiondir) $(testext_la_OBJECTS) $(testext_la_LIBADD) $(LIBS)
@@ -718,6 +748,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/errno.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filefuncs.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fnmatch.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fork.Plo@am__quote@
@@ -729,6 +760,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/revoutput.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/revtwoway.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rwarray.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/select.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stack.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testext.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time.Plo@am__quote@
diff --git a/extension/configh.in b/extension/configh.in
index 5842f2f4..57c9ec3e 100644
--- a/extension/configh.in
+++ b/extension/configh.in
@@ -40,6 +40,9 @@
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
+/* Define to 1 if you have the `fcntl' function. */
+#undef HAVE_FCNTL
+
/* Define to 1 if you have the `fdopendir' function. */
#undef HAVE_FDOPENDIR
@@ -67,6 +70,9 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
+/* Define to 1 if you have the `kill' function. */
+#undef HAVE_KILL
+
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
@@ -82,6 +88,15 @@
/* Define to 1 if you have the `select' function. */
#undef HAVE_SELECT
+/* Define to 1 if you have the `sigaction' function. */
+#undef HAVE_SIGACTION
+
+/* Define to 1 if you have the <signal.h> header file. */
+#undef HAVE_SIGNAL_H
+
+/* Define to 1 if you have the `sigprocmask' function. */
+#undef HAVE_SIGPROCMASK
+
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
diff --git a/extension/configure b/extension/configure
index 2105648d..006c9d79 100755
--- a/extension/configure
+++ b/extension/configure
@@ -14052,7 +14052,7 @@ else
$as_echo "no" >&6; }
fi
-for ac_header in fnmatch.h limits.h sys/time.h sys/select.h sys/param.h
+for ac_header in fnmatch.h limits.h sys/time.h sys/select.h sys/param.h signal.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -14309,8 +14309,9 @@ $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h
fi
-for ac_func in fdopendir fnmatch gettimeofday \
- getdtablesize nanosleep select GetSystemTimeAsFileTime
+for ac_func in fcntl fdopendir fnmatch gettimeofday \
+ getdtablesize kill nanosleep select sigaction sigprocmask \
+ GetSystemTimeAsFileTime
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/extension/configure.ac b/extension/configure.ac
index 1f876a0e..37e306f3 100644
--- a/extension/configure.ac
+++ b/extension/configure.ac
@@ -66,13 +66,14 @@ else
AC_MSG_RESULT([no])
fi
-AC_CHECK_HEADERS(fnmatch.h limits.h sys/time.h sys/select.h sys/param.h)
+AC_CHECK_HEADERS(fnmatch.h limits.h sys/time.h sys/select.h sys/param.h signal.h)
AC_HEADER_DIRENT
AC_HEADER_MAJOR
AC_HEADER_TIME
-AC_CHECK_FUNCS(fdopendir fnmatch gettimeofday \
- getdtablesize nanosleep select GetSystemTimeAsFileTime)
+AC_CHECK_FUNCS(fcntl fdopendir fnmatch gettimeofday \
+ getdtablesize kill nanosleep select sigaction sigprocmask \
+ GetSystemTimeAsFileTime)
GAWK_FUNC_DIRFD
GAWK_PREREQ_DIRFD
diff --git a/extension/errlist.h b/extension/errlist.h
new file mode 100644
index 00000000..caa6d63b
--- /dev/null
+++ b/extension/errlist.h
@@ -0,0 +1,455 @@
+/*
+ * errlist.h - List of errno values.
+ */
+
+/*
+ * Copyright (C) 2013 the Free Software Foundation, Inc.
+ *
+ * This file is part of GAWK, the GNU implementation of the
+ * AWK Programming Language.
+ *
+ * GAWK is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GAWK is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifdef E2BIG
+init_errno (E2BIG, "E2BIG")
+#endif
+#ifdef EACCES
+init_errno (EACCES, "EACCES")
+#endif
+#ifdef EADDRINUSE
+init_errno (EADDRINUSE, "EADDRINUSE")
+#endif
+#ifdef EADDRNOTAVAIL
+init_errno (EADDRNOTAVAIL, "EADDRNOTAVAIL")
+#endif
+#ifdef EADV
+init_errno (EADV, "EADV")
+#endif
+#ifdef EAFNOSUPPORT
+init_errno (EAFNOSUPPORT, "EAFNOSUPPORT")
+#endif
+#ifdef EAGAIN
+init_errno (EAGAIN, "EAGAIN")
+#endif
+#ifdef EALREADY
+init_errno (EALREADY, "EALREADY")
+#endif
+#ifdef EAUTH
+init_errno (EAUTH, "EAUTH")
+#endif
+#ifdef EBADE
+init_errno (EBADE, "EBADE")
+#endif
+#ifdef EBADF
+init_errno (EBADF, "EBADF")
+#endif
+#ifdef EBADFD
+init_errno (EBADFD, "EBADFD")
+#endif
+#ifdef EBADMSG
+init_errno (EBADMSG, "EBADMSG")
+#endif
+#ifdef EBADR
+init_errno (EBADR, "EBADR")
+#endif
+#ifdef EBADRPC
+init_errno (EBADRPC, "EBADRPC")
+#endif
+#ifdef EBADRQC
+init_errno (EBADRQC, "EBADRQC")
+#endif
+#ifdef EBADSLT
+init_errno (EBADSLT, "EBADSLT")
+#endif
+#ifdef EBFONT
+init_errno (EBFONT, "EBFONT")
+#endif
+#ifdef EBUSY
+init_errno (EBUSY, "EBUSY")
+#endif
+#ifdef ECANCELED
+init_errno (ECANCELED, "ECANCELED")
+#endif
+#ifdef ECHILD
+init_errno (ECHILD, "ECHILD")
+#endif
+#ifdef ECHRNG
+init_errno (ECHRNG, "ECHRNG")
+#endif
+#ifdef ECOMM
+init_errno (ECOMM, "ECOMM")
+#endif
+#ifdef ECONNABORTED
+init_errno (ECONNABORTED, "ECONNABORTED")
+#endif
+#ifdef ECONNREFUSED
+init_errno (ECONNREFUSED, "ECONNREFUSED")
+#endif
+#ifdef ECONNRESET
+init_errno (ECONNRESET, "ECONNRESET")
+#endif
+#ifdef EDEADLK
+init_errno (EDEADLK, "EDEADLK")
+#endif
+#ifdef EDEADLOCK
+#if !defined(EDEADLK) || (EDEADLK != EDEADLOCK)
+init_errno (EDEADLOCK, "EDEADLOCK")
+#endif
+#endif
+#ifdef EDESTADDRREQ
+init_errno (EDESTADDRREQ, "EDESTADDRREQ")
+#endif
+#ifdef EDOM
+init_errno (EDOM, "EDOM")
+#endif
+#ifdef EDOTDOT
+init_errno (EDOTDOT, "EDOTDOT")
+#endif
+#ifdef EDQUOT
+init_errno (EDQUOT, "EDQUOT")
+#endif
+#ifdef EEXIST
+init_errno (EEXIST, "EEXIST")
+#endif
+#ifdef EFAULT
+init_errno (EFAULT, "EFAULT")
+#endif
+#ifdef EFBIG
+init_errno (EFBIG, "EFBIG")
+#endif
+#ifdef EFTYPE
+init_errno (EFTYPE, "EFTYPE")
+#endif
+#ifdef EHOSTDOWN
+init_errno (EHOSTDOWN, "EHOSTDOWN")
+#endif
+#ifdef EHOSTUNREACH
+init_errno (EHOSTUNREACH, "EHOSTUNREACH")
+#endif
+#ifdef EIDRM
+init_errno (EIDRM, "EIDRM")
+#endif
+#ifdef EILSEQ
+init_errno (EILSEQ, "EILSEQ")
+#endif
+#ifdef EINPROGRESS
+init_errno (EINPROGRESS, "EINPROGRESS")
+#endif
+#ifdef EINTR
+init_errno (EINTR, "EINTR")
+#endif
+#ifdef EINVAL
+init_errno (EINVAL, "EINVAL")
+#endif
+#ifdef EIO
+init_errno (EIO, "EIO")
+#endif
+#ifdef EISCONN
+init_errno (EISCONN, "EISCONN")
+#endif
+#ifdef EISDIR
+init_errno (EISDIR, "EISDIR")
+#endif
+#ifdef EISNAM
+init_errno (EISNAM, "EISNAM")
+#endif
+#ifdef EKEYEXPIRED
+init_errno (EKEYEXPIRED, "EKEYEXPIRED")
+#endif
+#ifdef EKEYREJECTED
+init_errno (EKEYREJECTED, "EKEYREJECTED")
+#endif
+#ifdef EKEYREVOKED
+init_errno (EKEYREVOKED, "EKEYREVOKED")
+#endif
+#ifdef EL2HLT
+init_errno (EL2HLT, "EL2HLT")
+#endif
+#ifdef EL2NSYNC
+init_errno (EL2NSYNC, "EL2NSYNC")
+#endif
+#ifdef EL3HLT
+init_errno (EL3HLT, "EL3HLT")
+#endif
+#ifdef EL3RST
+init_errno (EL3RST, "EL3RST")
+#endif
+#ifdef ELAST
+init_errno (ELAST, "ELAST")
+#endif
+#ifdef ELIBACC
+init_errno (ELIBACC, "ELIBACC")
+#endif
+#ifdef ELIBBAD
+init_errno (ELIBBAD, "ELIBBAD")
+#endif
+#ifdef ELIBEXEC
+init_errno (ELIBEXEC, "ELIBEXEC")
+#endif
+#ifdef ELIBMAX
+init_errno (ELIBMAX, "ELIBMAX")
+#endif
+#ifdef ELIBSCN
+init_errno (ELIBSCN, "ELIBSCN")
+#endif
+#ifdef ELNRNG
+init_errno (ELNRNG, "ELNRNG")
+#endif
+#ifdef ELOOP
+init_errno (ELOOP, "ELOOP")
+#endif
+#ifdef EMEDIUMTYPE
+init_errno (EMEDIUMTYPE, "EMEDIUMTYPE")
+#endif
+#ifdef EMFILE
+init_errno (EMFILE, "EMFILE")
+#endif
+#ifdef EMLINK
+init_errno (EMLINK, "EMLINK")
+#endif
+#ifdef EMSGSIZE
+init_errno (EMSGSIZE, "EMSGSIZE")
+#endif
+#ifdef EMULTIHOP
+init_errno (EMULTIHOP, "EMULTIHOP")
+#endif
+#ifdef ENAMETOOLONG
+init_errno (ENAMETOOLONG, "ENAMETOOLONG")
+#endif
+#ifdef ENAVAIL
+init_errno (ENAVAIL, "ENAVAIL")
+#endif
+#ifdef ENEEDAUTH
+init_errno (ENEEDAUTH, "ENEEDAUTH")
+#endif
+#ifdef ENETDOWN
+init_errno (ENETDOWN, "ENETDOWN")
+#endif
+#ifdef ENETRESET
+init_errno (ENETRESET, "ENETRESET")
+#endif
+#ifdef ENETUNREACH
+init_errno (ENETUNREACH, "ENETUNREACH")
+#endif
+#ifdef ENFILE
+init_errno (ENFILE, "ENFILE")
+#endif
+#ifdef ENOANO
+init_errno (ENOANO, "ENOANO")
+#endif
+#ifdef ENOBUFS
+init_errno (ENOBUFS, "ENOBUFS")
+#endif
+#ifdef ENOCSI
+init_errno (ENOCSI, "ENOCSI")
+#endif
+#ifdef ENODATA
+init_errno (ENODATA, "ENODATA")
+#endif
+#ifdef ENODEV
+init_errno (ENODEV, "ENODEV")
+#endif
+#ifdef ENOENT
+init_errno (ENOENT, "ENOENT")
+#endif
+#ifdef ENOEXEC
+init_errno (ENOEXEC, "ENOEXEC")
+#endif
+#ifdef ENOKEY
+init_errno (ENOKEY, "ENOKEY")
+#endif
+#ifdef ENOLCK
+init_errno (ENOLCK, "ENOLCK")
+#endif
+#ifdef ENOLINK
+init_errno (ENOLINK, "ENOLINK")
+#endif
+#ifdef ENOMEDIUM
+init_errno (ENOMEDIUM, "ENOMEDIUM")
+#endif
+#ifdef ENOMEM
+init_errno (ENOMEM, "ENOMEM")
+#endif
+#ifdef ENOMSG
+init_errno (ENOMSG, "ENOMSG")
+#endif
+#ifdef ENONET
+init_errno (ENONET, "ENONET")
+#endif
+#ifdef ENOPKG
+init_errno (ENOPKG, "ENOPKG")
+#endif
+#ifdef ENOPROTOOPT
+init_errno (ENOPROTOOPT, "ENOPROTOOPT")
+#endif
+#ifdef ENOSPC
+init_errno (ENOSPC, "ENOSPC")
+#endif
+#ifdef ENOSR
+init_errno (ENOSR, "ENOSR")
+#endif
+#ifdef ENOSTR
+init_errno (ENOSTR, "ENOSTR")
+#endif
+#ifdef ENOSYS
+init_errno (ENOSYS, "ENOSYS")
+#endif
+#ifdef ENOTBLK
+init_errno (ENOTBLK, "ENOTBLK")
+#endif
+#ifdef ENOTCONN
+init_errno (ENOTCONN, "ENOTCONN")
+#endif
+#ifdef ENOTDIR
+init_errno (ENOTDIR, "ENOTDIR")
+#endif
+#ifdef ENOTEMPTY
+init_errno (ENOTEMPTY, "ENOTEMPTY")
+#endif
+#ifdef ENOTNAM
+init_errno (ENOTNAM, "ENOTNAM")
+#endif
+#ifdef ENOTRECOVERABLE
+init_errno (ENOTRECOVERABLE, "ENOTRECOVERABLE")
+#endif
+#ifdef ENOTSOCK
+init_errno (ENOTSOCK, "ENOTSOCK")
+#endif
+#ifdef ENOTTY
+init_errno (ENOTTY, "ENOTTY")
+#endif
+#ifdef ENOTUNIQ
+init_errno (ENOTUNIQ, "ENOTUNIQ")
+#endif
+#ifdef ENXIO
+init_errno (ENXIO, "ENXIO")
+#endif
+#ifdef EOPNOTSUPP
+init_errno (EOPNOTSUPP, "EOPNOTSUPP")
+#endif
+#ifdef EOVERFLOW
+init_errno (EOVERFLOW, "EOVERFLOW")
+#endif
+#ifdef EOWNERDEAD
+init_errno (EOWNERDEAD, "EOWNERDEAD")
+#endif
+#ifdef EPERM
+init_errno (EPERM, "EPERM")
+#endif
+#ifdef EPFNOSUPPORT
+init_errno (EPFNOSUPPORT, "EPFNOSUPPORT")
+#endif
+#ifdef EPIPE
+init_errno (EPIPE, "EPIPE")
+#endif
+#ifdef EPROCLIM
+init_errno (EPROCLIM, "EPROCLIM")
+#endif
+#ifdef EPROCUNAVAIL
+init_errno (EPROCUNAVAIL, "EPROCUNAVAIL")
+#endif
+#ifdef EPROGMISMATCH
+init_errno (EPROGMISMATCH, "EPROGMISMATCH")
+#endif
+#ifdef EPROGUNAVAIL
+init_errno (EPROGUNAVAIL, "EPROGUNAVAIL")
+#endif
+#ifdef EPROTO
+init_errno (EPROTO, "EPROTO")
+#endif
+#ifdef EPROTONOSUPPORT
+init_errno (EPROTONOSUPPORT, "EPROTONOSUPPORT")
+#endif
+#ifdef EPROTOTYPE
+init_errno (EPROTOTYPE, "EPROTOTYPE")
+#endif
+#ifdef ERANGE
+init_errno (ERANGE, "ERANGE")
+#endif
+#ifdef EREMCHG
+init_errno (EREMCHG, "EREMCHG")
+#endif
+#ifdef EREMOTE
+init_errno (EREMOTE, "EREMOTE")
+#endif
+#ifdef EREMOTEIO
+init_errno (EREMOTEIO, "EREMOTEIO")
+#endif
+#ifdef ERESTART
+init_errno (ERESTART, "ERESTART")
+#endif
+#ifdef ERFKILL
+init_errno (ERFKILL, "ERFKILL")
+#endif
+#ifdef EROFS
+init_errno (EROFS, "EROFS")
+#endif
+#ifdef ERPCMISMATCH
+init_errno (ERPCMISMATCH, "ERPCMISMATCH")
+#endif
+#ifdef ESHUTDOWN
+init_errno (ESHUTDOWN, "ESHUTDOWN")
+#endif
+#ifdef ESOCKTNOSUPPORT
+init_errno (ESOCKTNOSUPPORT, "ESOCKTNOSUPPORT")
+#endif
+#ifdef ESPIPE
+init_errno (ESPIPE, "ESPIPE")
+#endif
+#ifdef ESRCH
+init_errno (ESRCH, "ESRCH")
+#endif
+#ifdef ESRMNT
+init_errno (ESRMNT, "ESRMNT")
+#endif
+#ifdef ESTALE
+init_errno (ESTALE, "ESTALE")
+#endif
+#ifdef ESTRPIPE
+init_errno (ESTRPIPE, "ESTRPIPE")
+#endif
+#ifdef ETIME
+init_errno (ETIME, "ETIME")
+#endif
+#ifdef ETIMEDOUT
+init_errno (ETIMEDOUT, "ETIMEDOUT")
+#endif
+#ifdef ETOOMANYREFS
+init_errno (ETOOMANYREFS, "ETOOMANYREFS")
+#endif
+#ifdef ETXTBSY
+init_errno (ETXTBSY, "ETXTBSY")
+#endif
+#ifdef EUCLEAN
+init_errno (EUCLEAN, "EUCLEAN")
+#endif
+#ifdef EUNATCH
+init_errno (EUNATCH, "EUNATCH")
+#endif
+#ifdef EUSERS
+init_errno (EUSERS, "EUSERS")
+#endif
+#ifdef EWOULDBLOCK
+#if !defined(EAGAIN) || (EWOULDBLOCK != EAGAIN)
+init_errno (EWOULDBLOCK, "EWOULDBLOCK")
+#endif
+#endif
+#ifdef EXDEV
+init_errno (EXDEV, "EXDEV")
+#endif
+#ifdef EXFULL
+init_errno (EXFULL, "EXFULL")
+#endif
diff --git a/extension/errno.c b/extension/errno.c
new file mode 100644
index 00000000..2eafa437
--- /dev/null
+++ b/extension/errno.c
@@ -0,0 +1,145 @@
+/*
+ * errno.c - Builtin functions to map errno values.
+ */
+
+/*
+ * Copyright (C) 2013 the Free Software Foundation, Inc.
+ *
+ * This file is part of GAWK, the GNU implementation of the
+ * AWK Programming Language.
+ *
+ * GAWK is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GAWK is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "gawkapi.h"
+
+#include "gettext.h"
+#define _(msgid) gettext(msgid)
+#define N_(msgid) msgid
+
+static const gawk_api_t *api; /* for convenience macros to work */
+static awk_ext_id_t *ext_id;
+static const char *ext_version = "errno extension: version 1.0";
+static awk_bool_t (*init_func)(void) = NULL;
+
+int plugin_is_GPL_compatible;
+
+static const char *const errno2name[] = {
+#define init_errno(A, B) [A] = B,
+#include "errlist.h"
+#undef init_errno
+};
+#define NUMERR sizeof(errno2name)/sizeof(errno2name[0])
+
+/* do_strerror --- call strerror */
+
+static awk_value_t *
+do_strerror(int nargs, awk_value_t *result)
+{
+ awk_value_t errnum;
+
+ if (do_lint && nargs > 1)
+ lintwarn(ext_id, _("strerror: called with too many arguments"));
+
+ if (get_argument(0, AWK_NUMBER, & errnum)) {
+ const char *str = gettext(strerror(errnum.num_value));
+ return make_const_string(str, strlen(str), result);
+ }
+ if (do_lint) {
+ if (nargs == 0)
+ lintwarn(ext_id, _("strerror: called with no arguments"));
+ else
+ lintwarn(ext_id, _("strerror: called with inappropriate argument(s)"));
+ }
+ return make_null_string(result);
+}
+
+/* do_errno2name --- convert an integer errno value to it's symbolic name */
+
+static awk_value_t *
+do_errno2name(int nargs, awk_value_t *result)
+{
+ awk_value_t errnum;
+ const char *str;
+
+ if (do_lint && nargs > 1)
+ lintwarn(ext_id, _("errno2name: called with too many arguments"));
+
+ if (get_argument(0, AWK_NUMBER, & errnum)) {
+ int i = errnum.num_value;
+
+ if ((i == errnum.num_value) && (i >= 0) && ((size_t)i < NUMERR) && errno2name[i])
+ return make_const_string(errno2name[i], strlen(errno2name[i]), result);
+ warning(ext_id, _("errno2name: called with invalid argument"));
+ } else if (do_lint) {
+ if (nargs == 0)
+ lintwarn(ext_id, _("errno2name: called with no arguments"));
+ else
+ lintwarn(ext_id, _("errno2name: called with inappropriate argument(s)"));
+ }
+ return make_null_string(result);
+}
+
+/* do_name2errno --- convert a symbolic errno name to an integer */
+
+static awk_value_t *
+do_name2errno(int nargs, awk_value_t *result)
+{
+ awk_value_t err;
+ const char *str;
+
+ if (do_lint && nargs > 1)
+ lintwarn(ext_id, _("name2errno: called with too many arguments"));
+
+ if (get_argument(0, AWK_STRING, & err)) {
+ size_t i;
+
+ for (i = 0; i < NUMERR; i++) {
+ if (errno2name[i] && ! strcasecmp(err.str_value.str, errno2name[i]))
+ return make_number(i, result);
+ }
+ warning(ext_id, _("name2errno: called with invalid argument"));
+ } else if (do_lint) {
+ if (nargs == 0)
+ lintwarn(ext_id, _("name2errno: called with no arguments"));
+ else
+ lintwarn(ext_id, _("name2errno: called with inappropriate argument(s)"));
+ }
+ return make_number(-1, result);
+}
+
+static awk_ext_func_t func_table[] = {
+ { "strerror", do_strerror, 1 },
+ { "errno2name", do_errno2name, 1 },
+ { "name2errno", do_name2errno, 1 },
+};
+
+/* define the dl_load function using the boilerplate macro */
+
+dl_load_func(func_table, errno, "")
diff --git a/extension/select.c b/extension/select.c
new file mode 100644
index 00000000..9aefaeac
--- /dev/null
+++ b/extension/select.c
@@ -0,0 +1,544 @@
+/*
+ * select.c - Builtin functions to provide select I/O multiplexing.
+ */
+
+/*
+ * Copyright (C) 2013 the Free Software Foundation, Inc.
+ *
+ * This file is part of GAWK, the GNU implementation of the
+ * AWK Programming Language.
+ *
+ * GAWK is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GAWK is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "gawkapi.h"
+
+#include "gettext.h"
+#define _(msgid) gettext(msgid)
+#define N_(msgid) msgid
+
+static const gawk_api_t *api; /* for convenience macros to work */
+static awk_ext_id_t *ext_id;
+static const char *ext_version = "select extension: version 1.0";
+static awk_bool_t (*init_func)(void) = NULL;
+
+int plugin_is_GPL_compatible;
+
+#if defined(HAVE_SELECT) && defined(HAVE_SYS_SELECT_H)
+#include <sys/select.h>
+#endif
+
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
+
+static const char *const signum2name[] = {
+#define init_sig(A, B, C) [A] = B,
+#include "siglist.h"
+#undef init_sig
+};
+#define NUMSIG sizeof(signum2name)/sizeof(signum2name[0])
+
+#define MIN_VALID_SIGNAL 1 /* 0 is not allowed! */
+/*
+ * We would like to use NSIG, but I think this seems to be a BSD'ism that is not
+ * POSIX-compliant. It is used internally by glibc, but not always
+ * available. We add a buffer to the maximum number in the provided mapping
+ * in case the list is not comprehensive:
+ */
+#define MAX_VALID_SIGNAL (NUMSIG+100)
+#define IS_VALID_SIGNAL(X) \
+ (((X) >= MIN_VALID_SIGNAL) && ((X) <= MAX_VALID_SIGNAL))
+
+static int
+signame2num(const char *name)
+{
+ size_t i;
+
+ if (strncasecmp(name, "sig", 3) == 0)
+ /* skip "sig" prefix */
+ name += 3;
+ for (i = MIN_VALID_SIGNAL; i < NUMSIG; i++) {
+ if (signum2name[i] && ! strcasecmp(signum2name[i], name))
+ return i;
+ }
+ return -1;
+}
+
+static volatile struct {
+ int flag;
+ sigset_t mask;
+} caught;
+
+static void
+signal_handler(int signum)
+{
+ /*
+ * All signals should be blocked, so we do not have to worry about
+ * whether sigaddset is thread-safe. It is documented to be
+ * async-signal-safe.
+ */
+ sigaddset(& caught.mask, signum);
+ caught.flag = 1;
+#ifndef HAVE_SIGACTION
+ /*
+ * On platforms without sigaction, we do not know how the legacy
+ * signal API will behave. There does not appear to be an autoconf
+ * test for whether the signal handler is reset to default each time
+ * a signal is trapped, so we do this to be safe.
+ */
+ signal(signum, signal_handler);
+#endif
+}
+
+static int
+integer_string(const char *s, long *x)
+{
+ char *endptr;
+
+ *x = strtol(s, & endptr, 10);
+ return ((endptr != s) && (*endptr == '\0')) ? 0 : -1;
+}
+
+static int
+get_signal_number(awk_value_t signame)
+{
+ int x;
+
+ switch (signame.val_type) {
+ case AWK_NUMBER:
+ x = signame.num_value;
+ if ((x != signame.num_value) || ! IS_VALID_SIGNAL(x)) {
+ update_ERRNO_string(_("invalid signal number"));
+ return -1;
+ }
+ return x;
+ case AWK_STRING:
+ if ((x = signame2num(signame.str_value.str)) >= 0)
+ return x;
+ {
+ long z;
+ if ((integer_string(signame.str_value.str, &z) == 0) && IS_VALID_SIGNAL(z))
+ return z;
+ }
+ update_ERRNO_string(_("invalid signal name"));
+ return -1;
+ default:
+ update_ERRNO_string(_("signal name argument must be string or numeric"));
+ return -1;
+ }
+}
+
+static awk_value_t *
+signal_result(awk_value_t *result, void (*func)(int))
+{
+ awk_value_t override;
+
+ if (func == SIG_DFL)
+ return make_const_string("default", 7, result);
+ if (func == SIG_IGN)
+ return make_const_string("ignore", 6, result);
+ if (func == signal_handler)
+ return make_const_string("trap", 4, result);
+ if (get_argument(2, AWK_NUMBER, & override) && override.num_value)
+ return make_const_string("unknown", 7, result);
+ /* need to roll it back! */
+ update_ERRNO_string(_("select_signal: override not requested for unknown signal handler"));
+ make_null_string(result);
+ return NULL;
+}
+
+/* do_signal --- trap signals */
+
+static awk_value_t *
+do_signal(int nargs, awk_value_t *result)
+{
+ awk_value_t signame, disposition;
+ int signum;
+ void (*func)(int);
+
+ if (do_lint && nargs > 3)
+ lintwarn(ext_id, _("select_signal: called with too many arguments"));
+ if (! get_argument(0, AWK_UNDEFINED, & signame)) {
+ update_ERRNO_string(_("select_signal: missing required signal name argument"));
+ return make_null_string(result);
+ }
+ if ((signum = get_signal_number(signame)) < 0)
+ return make_null_string(result);
+ if (! get_argument(1, AWK_STRING, & disposition)) {
+ update_ERRNO_string(_("select_signal: missing required signal disposition argument"));
+ return make_null_string(result);
+ }
+ if (strcasecmp(disposition.str_value.str, "default") == 0)
+ func = SIG_DFL;
+ else if (strcasecmp(disposition.str_value.str, "ignore") == 0)
+ func = SIG_IGN;
+ else if (strcasecmp(disposition.str_value.str, "trap") == 0)
+ func = signal_handler;
+ else {
+ update_ERRNO_string(_("select_signal: invalid disposition argument"));
+ return make_null_string(result);
+ }
+
+#ifdef HAVE_SIGPROCMASK
+/* Temporarily block this signal in case we need to roll back the handler! */
+#define PROTECT \
+ sigset_t set, oldset; \
+ sigemptyset(& set); \
+ sigaddset(& set, signum); \
+ sigprocmask(SIG_BLOCK, &set, &oldset);
+#define RELEASE sigprocmask(SIG_SETMASK, &oldset, NULL);
+#else
+/* Brain-damaged platform, so we will have to live with the race condition. */
+#define PROTECT
+#define RELEASE
+#endif
+
+#ifdef HAVE_SIGACTION
+ {
+ awk_value_t override;
+ struct sigaction sa, prev;
+ sa.sa_handler = func;
+ sigfillset(& sa.sa_mask); /* block all signals in handler */
+ sa.sa_flags = SA_RESTART;
+ {
+ PROTECT
+ if (sigaction(signum, &sa, &prev) < 0) {
+ update_ERRNO_int(errno);
+ RELEASE
+ return make_null_string(result);
+ }
+ if (signal_result(result, prev.sa_handler)) {
+ RELEASE
+ return result;
+ }
+ /* roll it back! */
+ sigaction(signum, &prev, NULL);
+ RELEASE
+ return result;
+ }
+ }
+#else
+ /*
+ * Fall back to signal; this is available on all platforms. We can
+ * only hope that it does the right thing.
+ */
+ {
+ void (*prev)(int);
+ PROTECT
+ if ((prev = signal(signum, func)) == SIG_ERR) {
+ update_ERRNO_int(errno);
+ RELEASE
+ return make_null_string(result);
+ }
+ if (signal_result(result, prev)) {
+ RELEASE
+ return result;
+ }
+ /* roll it back! */
+ signal(signum, prev);
+ RELEASE
+ return result;
+ }
+#endif
+}
+
+/* do_kill --- send a signal */
+
+static awk_value_t *
+do_kill(int nargs, awk_value_t *result)
+{
+#ifdef HAVE_KILL
+ awk_value_t pidarg, signame;
+ pid_t pid;
+ int signum;
+ int rc;
+
+ if (do_lint && nargs > 2)
+ lintwarn(ext_id, _("kill: called with too many arguments"));
+ if (! get_argument(0, AWK_NUMBER, & pidarg)) {
+ update_ERRNO_string(_("kill: missing required pid argument"));
+ return make_number(-1, result);
+ }
+ pid = pidarg.num_value;
+ if (pid != pidarg.num_value) {
+ update_ERRNO_string(_("kill: pid argument must be an integer"));
+ return make_number(-1, result);
+ }
+ if (! get_argument(1, AWK_UNDEFINED, & signame)) {
+ update_ERRNO_string(_("kill: missing required signal name argument"));
+ return make_number(-1, result);
+ }
+ if ((signum = get_signal_number(signame)) < 0)
+ return make_number(-1, result);
+ if ((rc = kill(pid, signum)) < 0)
+ update_ERRNO_int(errno);
+ return make_number(rc, result);
+#else
+ update_ERRNO_string(_("kill: not supported on this platform"));
+ return make_number(-1, result);
+#endif
+}
+
+/* do_select --- I/O multiplexing */
+
+static awk_value_t *
+do_select(int nargs, awk_value_t *result)
+{
+ static const char *argname[] = { "read", "write", "except" };
+ struct {
+ awk_value_t array;
+ awk_flat_array_t *flat;
+ fd_set bits;
+ int *array2fd;
+ } fds[3];
+ awk_value_t timeout_arg;
+ int i;
+ struct timeval maxwait;
+ struct timeval *timeout;
+ int nfds = 0;
+ int rc;
+ awk_value_t sigarr;
+ int dosig = 0;
+
+ if (do_lint && nargs > 5)
+ lintwarn(ext_id, _("select: called with too many arguments"));
+
+#define EL fds[i].flat->elements[j]
+ if (nargs == 5) {
+ dosig = 1;
+ if (! get_argument(4, AWK_ARRAY, &sigarr)) {
+ warning(ext_id, _("select: the signal argument must be an array"));
+ update_ERRNO_string(_("select: bad signal parameter"));
+ return make_number(-1, result);
+ }
+ clear_array(sigarr.array_cookie);
+ }
+
+ for (i = 0; i < sizeof(fds)/sizeof(fds[0]); i++) {
+ size_t j;
+
+ if (! get_argument(i, AWK_ARRAY, & fds[i].array)) {
+ warning(ext_id, _("select: bad array parameter `%s'"), argname[i]);
+ update_ERRNO_string(_("select: bad array parameter"));
+ return make_number(-1, result);
+ }
+ /* N.B. flatten_array fails for empty arrays, so that's OK */
+ FD_ZERO(&fds[i].bits);
+ if (flatten_array(fds[i].array.array_cookie, &fds[i].flat)) {
+ emalloc(fds[i].array2fd, int *, fds[i].flat->count*sizeof(int), "select");
+ for (j = 0; j < fds[i].flat->count; j++) {
+ long x;
+ fds[i].array2fd[j] = -1;
+ /* note: the index is always delivered as a string */
+
+ if (((EL.value.val_type == AWK_UNDEFINED) || ((EL.value.val_type == AWK_STRING) && ! EL.value.str_value.len)) && (integer_string(EL.index.str_value.str, &x) == 0) && (x >= 0))
+ fds[i].array2fd[j] = x;
+ else if (EL.value.val_type == AWK_STRING) {
+ const awk_input_buf_t *buf;
+ if ((buf = get_file(EL.index.str_value.str, EL.index.str_value.len, EL.value.str_value.str, EL.value.str_value.len)) != NULL)
+ fds[i].array2fd[j] = buf->fd;
+ else
+ warning(ext_id, _("select: get_file(`%s', `%s') failed in `%s' array"), EL.index.str_value.str, EL.value.str_value.str, argname[i]);
+ }
+ else
+ warning(ext_id, _("select: command type should be a string for `%s' in `%s' array"), EL.index.str_value.str, argname[i]);
+ if (fds[i].array2fd[j] < 0) {
+ update_ERRNO_string(_("select: get_file failed"));
+ if (! release_flattened_array(fds[i].array.array_cookie, fds[i].flat))
+ warning(ext_id, _("select: release_flattened_array failed"));
+ free(fds[i].array2fd);
+ return make_number(-1, result);
+ }
+ FD_SET(fds[i].array2fd[j], &fds[i].bits);
+ if (nfds <= fds[i].array2fd[j])
+ nfds = fds[i].array2fd[j]+1;
+ }
+ }
+ else
+ fds[i].flat = NULL;
+ }
+ if (dosig && caught.flag) {
+ /* take a quick poll, but do not block, since signals have been trapped */
+ maxwait.tv_sec = maxwait.tv_usec = 0;
+ timeout = &maxwait;
+ }
+ else if (get_argument(3, AWK_NUMBER, &timeout_arg)) {
+ double secs = timeout_arg.num_value;
+ if (secs < 0) {
+ warning(ext_id, _("select: treating negative timeout as zero"));
+ secs = 0;
+ }
+ maxwait.tv_sec = secs;
+ maxwait.tv_usec = (secs-(double)maxwait.tv_sec)*1000000.0;
+ timeout = &maxwait;
+ } else
+ timeout = NULL;
+
+ if ((rc = select(nfds, &fds[0].bits, &fds[1].bits, &fds[2].bits, timeout)) < 0)
+ update_ERRNO_int(errno);
+
+ if (dosig && caught.flag) {
+ int i;
+ sigset_t trapped;
+#ifdef HAVE_SIGPROCMASK
+ /*
+ * Block signals while we copy and reset the mask to eliminate
+ * a race condition whereby a signal could be missed.
+ */
+ sigset_t set, oldset;
+ sigfillset(& set);
+ sigprocmask(SIG_SETMASK, &set, &oldset);
+#endif
+ /*
+ * Reset flag to 0 first. If we don't have sigprocmask,
+ * that may reduce the chance of missing a signal.
+ */
+ caught.flag = 0;
+ trapped = caught.mask;
+ sigemptyset(& caught.mask);
+#ifdef HAVE_SIGPROCMASK
+ sigprocmask(SIG_SETMASK, &oldset, NULL);
+#endif
+ /* populate sigarr with trapped signals */
+ /*
+ * XXX this is very inefficient! Note that get_signal_number
+ * ensures that we trap only signals between MIN_VALID_SIGNAL
+ * and MAX_VALID_SIGNAL.
+ */
+ for (i = MIN_VALID_SIGNAL; i <= MAX_VALID_SIGNAL; i++) {
+ if (sigismember(& trapped, i) > 0) {
+ awk_value_t idx, val;
+ if ((i < NUMSIG) && signum2name[i])
+ set_array_element(sigarr.array_cookie, make_number(i, &idx), make_const_string(signum2name[i], strlen(signum2name[i]), &val));
+ else
+ set_array_element(sigarr.array_cookie, make_number(i, &idx), make_null_string(&val));
+ }
+ }
+ }
+
+ if (rc < 0) {
+ /* bit masks are undefined, so delete all array entries */
+ for (i = 0; i < sizeof(fds)/sizeof(fds[0]); i++) {
+ if (fds[i].flat) {
+ size_t j;
+ for (j = 0; j < fds[i].flat->count; j++)
+ EL.flags |= AWK_ELEMENT_DELETE;
+ if (! release_flattened_array(fds[i].array.array_cookie, fds[i].flat))
+ warning(ext_id, _("select: release_flattened_array failed"));
+ free(fds[i].array2fd);
+ }
+ }
+ return make_number(rc, result);
+ }
+
+ for (i = 0; i < sizeof(fds)/sizeof(fds[0]); i++) {
+ if (fds[i].flat) {
+ size_t j;
+ /* remove array elements not set in the bit mask */
+ for (j = 0; j < fds[i].flat->count; j++) {
+ if (! FD_ISSET(fds[i].array2fd[j], &fds[i].bits))
+ EL.flags |= AWK_ELEMENT_DELETE;
+ }
+ if (! release_flattened_array(fds[i].array.array_cookie, fds[i].flat))
+ warning(ext_id, _("select: release_flattened_array failed"));
+ free(fds[i].array2fd);
+ }
+ }
+#undef EL
+
+ /* Set the return value */
+ return make_number(rc, result);
+}
+
+static int
+set_non_blocking(int fd)
+{
+#if defined(HAVE_FCNTL) && defined(O_NONBLOCK)
+ int flags;
+
+ if (((flags = fcntl(fd, F_GETFL)) == -1) ||
+ (fcntl(fd, F_SETFL, (flags|O_NONBLOCK)) == -1)) {
+ update_ERRNO_int(errno);
+ return -1;
+ }
+ return 0;
+#else
+ update_ERRNO_string(_("set_non_blocking: not supported on this platform"));
+ return -1;
+#endif
+}
+
+/* do_set_non_blocking --- Set a file to be non-blocking */
+
+static awk_value_t *
+do_set_non_blocking(int nargs, awk_value_t *result)
+{
+ awk_value_t cmd, cmdtype;
+ int fd;
+
+ if (do_lint && nargs > 2)
+ lintwarn(ext_id, _("set_non_blocking: called with too many arguments"));
+ /*
+ * N.B. If called with a single "" arg, we want it to work! In that
+ * case, the 1st arg is an empty string, and get_argument fails on the
+ * 2nd arg. Note that API get_file promises not to access the type
+ * argument if the name argument is an empty string.
+ */
+ if (get_argument(0, AWK_NUMBER, & cmd) &&
+ (cmd.num_value == (fd = cmd.num_value)) &&
+ ! get_argument(1, AWK_STRING, & cmdtype))
+ return make_number(set_non_blocking(fd), result);
+ else if (get_argument(0, AWK_STRING, & cmd) &&
+ (get_argument(1, AWK_STRING, & cmdtype) ||
+ (! cmd.str_value.len && (nargs == 1)))) {
+ const awk_input_buf_t *buf;
+ if ((buf = get_file(cmd.str_value.str, cmd.str_value.len, cmdtype.str_value.str, cmdtype.str_value.len)) != NULL)
+ return make_number(set_non_blocking(buf->fd), result);
+ warning(ext_id, _("set_non_blocking: get_file(`%s', `%s') failed"), cmd.str_value.str, cmdtype.str_value.str);
+ } else if (do_lint) {
+ if (nargs < 2)
+ lintwarn(ext_id, _("set_non_blocking: called with too few arguments"));
+ else
+ lintwarn(ext_id, _("set_non_blocking: called with inappropriate argument(s)"));
+ }
+ return make_number(-1, result);
+}
+
+static awk_ext_func_t func_table[] = {
+ { "select", do_select, 5 },
+ { "select_signal", do_signal, 3 },
+ { "set_non_blocking", do_set_non_blocking, 2 },
+ { "kill", do_kill, 2 },
+};
+
+/* define the dl_load function using the boilerplate macro */
+
+dl_load_func(func_table, select, "")
diff --git a/extension/siglist.h b/extension/siglist.h
new file mode 100644
index 00000000..7ecb8ab1
--- /dev/null
+++ b/extension/siglist.h
@@ -0,0 +1,76 @@
+/* Canonical list of all signal names.
+ Copyright (C) 1996-2012 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* This file should be usable for any platform, since it just associates
+ the SIG* macros with text names and descriptions. The actual values
+ come from <bits/signum.h> (via <signal.h>). For any signal macros do not
+ exist on every platform, we can use #ifdef tests here and still use
+ this single common file for all platforms. */
+
+/* This file is included multiple times. */
+
+/* Standard signals */
+ init_sig (SIGHUP, "HUP", N_("Hangup"))
+ init_sig (SIGINT, "INT", N_("Interrupt"))
+ init_sig (SIGQUIT, "QUIT", N_("Quit"))
+ init_sig (SIGILL, "ILL", N_("Illegal instruction"))
+ init_sig (SIGTRAP, "TRAP", N_("Trace/breakpoint trap"))
+ init_sig (SIGABRT, "ABRT", N_("Aborted"))
+ init_sig (SIGFPE, "FPE", N_("Floating point exception"))
+ init_sig (SIGKILL, "KILL", N_("Killed"))
+ init_sig (SIGBUS, "BUS", N_("Bus error"))
+ init_sig (SIGSEGV, "SEGV", N_("Segmentation fault"))
+ init_sig (SIGPIPE, "PIPE", N_("Broken pipe"))
+ init_sig (SIGALRM, "ALRM", N_("Alarm clock"))
+ init_sig (SIGTERM, "TERM", N_("Terminated"))
+ init_sig (SIGURG, "URG", N_("Urgent I/O condition"))
+ init_sig (SIGSTOP, "STOP", N_("Stopped (signal)"))
+ init_sig (SIGTSTP, "TSTP", N_("Stopped"))
+ init_sig (SIGCONT, "CONT", N_("Continued"))
+ init_sig (SIGCHLD, "CHLD", N_("Child exited"))
+ init_sig (SIGTTIN, "TTIN", N_("Stopped (tty input)"))
+ init_sig (SIGTTOU, "TTOU", N_("Stopped (tty output)"))
+ init_sig (SIGIO, "IO", N_("I/O possible"))
+ init_sig (SIGXCPU, "XCPU", N_("CPU time limit exceeded"))
+ init_sig (SIGXFSZ, "XFSZ", N_("File size limit exceeded"))
+ init_sig (SIGVTALRM, "VTALRM", N_("Virtual timer expired"))
+ init_sig (SIGPROF, "PROF", N_("Profiling timer expired"))
+ init_sig (SIGUSR1, "USR1", N_("User defined signal 1"))
+ init_sig (SIGUSR2, "USR2", N_("User defined signal 2"))
+
+/* Variations */
+#ifdef SIGEMT
+ init_sig (SIGEMT, "EMT", N_("EMT trap"))
+#endif
+#ifdef SIGSYS
+ init_sig (SIGSYS, "SYS", N_("Bad system call"))
+#endif
+#ifdef SIGSTKFLT
+ init_sig (SIGSTKFLT, "STKFLT", N_("Stack fault"))
+#endif
+#ifdef SIGINFO
+ init_sig (SIGINFO, "INFO", N_("Information request"))
+#elif defined(SIGPWR) && (!defined(SIGLOST) || (SIGPWR != SIGLOST))
+ init_sig (SIGPWR, "PWR", N_("Power failure"))
+#endif
+#ifdef SIGLOST
+ init_sig (SIGLOST, "LOST", N_("Resource lost"))
+#endif
+#ifdef SIGWINCH
+ init_sig (SIGWINCH, "WINCH", N_("Window changed"))
+#endif
diff --git a/gawkapi.c b/gawkapi.c
index bcf8d90a..46aef7b6 100644
--- a/gawkapi.c
+++ b/gawkapi.c
@@ -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);
/*
@@ -1032,6 +1037,86 @@ 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 const awk_input_buf_t *
+api_get_file(awk_ext_id_t id, const char *name, size_t namelen, const char *filetype, size_t typelen)
+{
+ 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 NULL;
+ {
+ 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;
+ }
+ }
+ return &curfile->public;
+ }
+ 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 NULL;
+ }
+ if ((f = redirect_string(name, namelen, 0, redirtype, &flag)) == NULL)
+ return NULL;
+ return &f->iop->public;
+}
+
/*
* Register a version string for this extension with gawk.
*/
@@ -1117,6 +1202,9 @@ gawk_api_t api_impl = {
calloc,
realloc,
free,
+
+ /* Find/open a file */
+ api_get_file,
};
/* init_ext_api --- init the extension API */
diff --git a/gawkapi.h b/gawkapi.h
index d8215450..dbe7fdf8 100644
--- a/gawkapi.h
+++ b/gawkapi.h
@@ -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,21 @@ 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 "|&"
+ */
+ const awk_input_buf_t *(*api_get_file)(awk_ext_id_t id,
+ const char *name,
+ size_t name_len,
+ const char *filetype,
+ size_t typelen);
} gawk_api_t;
#ifndef GAWK /* these are not for the gawk code itself! */
@@ -756,6 +771,9 @@ typedef struct gawk_api {
#define release_value(value) \
(api->api_release_value(ext_id, value))
+#define get_file(name, namelen, filetype, typelen) \
+ (api->api_get_file(ext_id, name, namelen, filetype, typelen))
+
#define register_ext_version(version) \
(api->api_register_ext_version(ext_id, version))
diff --git a/io.c b/io.c
index 32caadfb..5692a519 100644
--- a/io.c
+++ b/io.c
@@ -588,7 +588,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);
@@ -719,10 +720,9 @@ redflags2str(int flags)
/* redirect --- Redirection for printf and print commands */
struct redirect *
-redirect(NODE *redir_exp, int redirtype, int *errflg)
+redirect_string(char *str, size_t explen, int not_string, int redirtype, int *errflg)
{
struct redirect *rp;
- char *str;
int tflag = 0;
int outflag = 0;
const char *direction = "to";
@@ -771,18 +771,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);
@@ -820,8 +818,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))) {
@@ -832,22 +830,24 @@ 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';
+ emalloc(newstr, char *, explen + 1, "redirect");
+ memcpy(newstr, str, explen);
+ newstr[explen] = '\0';
+ str = newstr;
rp->value = str;
rp->flag = tflag;
init_output_wrapper(& rp->output);
@@ -1036,6 +1036,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);
+}
+
/* getredirect --- find the struct redirect for this file or pipe */
struct redirect *
@@ -2160,17 +2169,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;
@@ -2187,10 +2222,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);
@@ -2208,10 +2249,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;
}
@@ -2432,7 +2479,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) {
@@ -2482,7 +2529,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)
@@ -3378,10 +3425,37 @@ find_longest_terminator:
return REC_OK;
}
+/* 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
@@ -3425,8 +3499,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())
+ return -2;
+ iop->flag |= IOP_AT_EOF;
return EOF;
} else {
iop->dataend = iop->buf + iop->count;
@@ -3500,6 +3576,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())
+ return -2;
iop->flag |= IOP_AT_EOF;
break;
} else if (iop->count == 0) {